public final class DateUtils extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.GregorianCalendar |
calendar
A shared instance used for conversion between individual date fields
and long millis time.
|
static BooleanProperty |
PROP_ISO_DATES
Property to enable display of ISO dates globally.
|
private static javax.xml.datatype.DatatypeFactory |
XML_DATE |
Modifier | Constructor and Description |
---|---|
private |
DateUtils() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
checkLayout(java.lang.String text,
java.lang.String pattern) |
static java.lang.String |
formatDate(java.util.Date date,
int dateStyle)
Formats a date to be displayed to current user, based on user preferences.
|
static java.lang.String |
formatDateTime(java.util.Date datetime,
int dateStyle,
int timeStyle)
Formats a date/time to be displayed to current user, based on user preferences.
|
static java.lang.String |
formatTime(java.util.Date time,
int timeStyle)
Formats a time to be displayed to current user, based on user preferences.
|
static java.lang.String |
fromDate(java.util.Date date)
Formats a date to the XML UTC format regardless of current locale.
|
static java.util.Date |
fromString(java.lang.String str)
Parses XML date quickly, regardless of current locale.
|
static java.text.DateFormat |
getDateFormat(int dateStyle)
Returns the date format to be used for current user, based on user preferences.
|
static java.text.DateFormat |
getDateTimeFormat(int dateStyle,
int timeStyle)
Returns the date/time format to be used for current user, based on user preferences.
|
static java.text.DateFormat |
getTimeFormat(int timeStyle)
Returns the time format to be used for current user, based on user preferences.
|
static java.text.SimpleDateFormat |
newIsoDateFormat()
Returns a new
SimpleDateFormat for date only, according to ISO 8601. |
static java.text.SimpleDateFormat |
newIsoDateTimeFormat()
Returns a new
SimpleDateFormat for date and time, according to ISO 8601. |
static java.text.SimpleDateFormat |
newOsmApiDateTimeFormat()
Returns a new
SimpleDateFormat for date and time, according to format used in OSM API errors. |
private static int |
parsePart(java.lang.String str,
int off,
int len) |
public static final BooleanProperty PROP_ISO_DATES
private static java.util.GregorianCalendar calendar
private static final javax.xml.datatype.DatatypeFactory XML_DATE
private DateUtils()
public static java.util.Date fromString(java.lang.String str)
str
- The XML date as stringpublic static java.lang.String fromDate(java.util.Date date)
date
- The date to formatprivate static boolean checkLayout(java.lang.String text, java.lang.String pattern)
private static int parsePart(java.lang.String str, int off, int len)
public static final java.text.SimpleDateFormat newIsoDateFormat()
SimpleDateFormat
for date only, according to ISO 8601.public static final java.text.SimpleDateFormat newIsoDateTimeFormat()
SimpleDateFormat
for date and time, according to ISO 8601.public static final java.text.SimpleDateFormat newOsmApiDateTimeFormat()
SimpleDateFormat
for date and time, according to format used in OSM API errors.public static final java.text.DateFormat getDateFormat(int dateStyle)
dateStyle
- The date style as described in DateFormat.getDateInstance()
. Ignored if "ISO dates" option is setpublic static final java.lang.String formatDate(java.util.Date date, int dateStyle)
date
- The date to display. Must not be null
dateStyle
- The date style as described in DateFormat.getDateInstance()
. Ignored if "ISO dates" option is setpublic static final java.text.DateFormat getTimeFormat(int timeStyle)
timeStyle
- The time style as described in DateFormat.getTimeInstance()
. Ignored if "ISO dates" option is setpublic static final java.lang.String formatTime(java.util.Date time, int timeStyle)
time
- The time to display. Must not be null
timeStyle
- The time style as described in DateFormat.getTimeInstance()
. Ignored if "ISO dates" option is setpublic static final java.text.DateFormat getDateTimeFormat(int dateStyle, int timeStyle)
dateStyle
- The date style as described in DateFormat.getDateTimeInstance()
. Ignored if "ISO dates" option is settimeStyle
- The time style as described in DateFormat.getDateTimeInstance
. Ignored if "ISO dates" option is setpublic static final java.lang.String formatDateTime(java.util.Date datetime, int dateStyle, int timeStyle)
datetime
- The date/time to display. Must not be null
dateStyle
- The date style as described in DateFormat.getDateTimeInstance()
. Ignored if "ISO dates" option is settimeStyle
- The time style as described in DateFormat.getDateTimeInstance
. Ignored if "ISO dates" option is set