Modifier and Type | Field and Description |
---|---|
private static 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 DatatypeFactory |
XML_DATE |
Modifier | Constructor and Description |
---|---|
private |
DateUtils() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
checkLayout(String text,
String pattern) |
static String |
formatDate(Date date,
int dateStyle)
Formats a date to be displayed to current user, based on user preferences.
|
static String |
formatDateTime(Date datetime,
int dateStyle,
int timeStyle)
Formats a date/time to be displayed to current user, based on user preferences.
|
static String |
formatTime(Date time,
int timeStyle)
Formats a time to be displayed to current user, based on user preferences.
|
static String |
fromDate(Date date)
Formats a date to the XML UTC format regardless of current locale.
|
static Date |
fromString(String str)
Parses XML date quickly, regardless of current locale.
|
static DateFormat |
getDateFormat(int dateStyle)
Returns the date format to be used for current user, based on user preferences.
|
static DateFormat |
getDateTimeFormat(int dateStyle,
int timeStyle)
Returns the date/time format to be used for current user, based on user preferences.
|
static DateFormat |
getTimeFormat(int timeStyle)
Returns the time format to be used for current user, based on user preferences.
|
static SimpleDateFormat |
newIsoDateFormat()
Returns a new
SimpleDateFormat for date only, according to ISO 8601. |
static SimpleDateFormat |
newIsoDateTimeFormat()
Returns a new
SimpleDateFormat for date and time, according to ISO 8601. |
static SimpleDateFormat |
newOsmApiDateTimeFormat()
Returns a new
SimpleDateFormat for date and time, according to format used in OSM API errors. |
private static int |
parsePart(String str,
int off,
int len) |
public static final BooleanProperty PROP_ISO_DATES
private static GregorianCalendar calendar
private static final DatatypeFactory XML_DATE
private DateUtils()
public static Date fromString(String str)
str
- The XML date as stringpublic static String fromDate(Date date)
date
- The date to formatprivate static boolean checkLayout(String text, String pattern)
public static final SimpleDateFormat newIsoDateFormat()
SimpleDateFormat
for date only, according to ISO 8601.public static final SimpleDateFormat newIsoDateTimeFormat()
SimpleDateFormat
for date and time, according to ISO 8601.public static final SimpleDateFormat newOsmApiDateTimeFormat()
SimpleDateFormat
for date and time, according to format used in OSM API errors.public static final DateFormat getDateFormat(int dateStyle)
dateStyle
- The date style as described in DateFormat.getDateInstance()
. Ignored if "ISO dates" option is setpublic static final String formatDate(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 DateFormat getTimeFormat(int timeStyle)
timeStyle
- The time style as described in DateFormat.getTimeInstance()
. Ignored if "ISO dates" option is setpublic static final String formatTime(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 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 String formatDateTime(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