public class DateUtils extends Object
Modifier and Type | Field and Description |
---|---|
static TimeZone |
MIDDAY
Custom time zone used to interpret date values without a time
component in a way that most likely falls within the same day
regardless of in which time zone it is later interpreted.
|
static TimeZone |
UTC
The UTC time zone.
|
Constructor and Description |
---|
DateUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
formatDate(Calendar date)
Returns a ISO 8601 representation of the given date.
|
static String |
formatDate(Date date)
Returns a ISO 8601 representation of the given date.
|
static String |
formatDateUnknownTimezone(Date date)
Returns a ISO 8601 representation of the given date, which is
in an unknown timezone.
|
Date |
tryToParse(String dateString)
Tries to parse the date string; returns null if no parse was possible.
|
public static final TimeZone UTC
TimeZone.getTimeZone(String)
understands "UTC" in all environments, but it'll fall back to GMT
in such cases, which is in practice equivalent to UTC.public static final TimeZone MIDDAY
public static String formatDate(Date date)
date
- given datepublic static String formatDate(Calendar date)
date
- given datepublic static String formatDateUnknownTimezone(Date date)
date
- given dateCopyright © 2007–2023 The Apache Software Foundation. All rights reserved.