public class DateUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FORMAT_DATE_LONG |
static String |
FORMAT_DATE_MEDIUM |
static String |
FORMAT_DATE_SHORT |
static String |
FORMAT_DATETIME_LONG |
static String |
FORMAT_DATETIME_MEDIUM |
static String |
FORMAT_DATETIME_SHORT |
static String |
FORMAT_DEFAULTPATTERN
Default date format.
|
static String |
FORMAT_TIME_LONG |
static String |
FORMAT_TIME_MEDIUM |
static String |
FORMAT_TIME_SHORT |
static TimeZone |
UTC_TIME_ZONE |
static String |
YYYY_MM_DD |
static String |
YYYY_MM_DD_T_HH_MM_SS |
Modifier and Type | Method and Description |
---|---|
static String |
createDateExpression(Calendar calendar)
Expression for searching - representing a date.
|
static String |
createDateTimeExpression(Calendar calendar)
Expression for searching - representing a date and time.
|
static String |
createDateTimeExpressionIgnoreTimeZone(Calendar calendar)
Expression for searching - not considering the timezone.
|
static String |
format(Date date,
String formatPattern)
Supports implicit formats like: date, date long, datetime, dateime long, time and time long.
|
static String |
format(Date date,
String formatPattern,
Locale locale) |
static String |
formatDate(Object val)
Uses the current locale (user) to format the date.
|
static String |
formatDateTime(Object val)
Uses the current locale (user) to format the date and time.
|
static Calendar |
getCurrentUTCCalendar()
Get UTC Calendar for current time.
|
static Calendar |
getLocalCalendarFromUTC(Calendar utc)
Get the equivalent UTC calendar to a local calendar.
|
static Calendar |
getUTCCalendarFromDialogString(String dateString)
Convert a string date from a dialog date to a UTC calendar ready to be stored in the repository.
|
static Calendar |
getUTCCalendarFromLocalDate(Date date)
Convert a local date time to a UTC calendar.
|
static Date |
parseDate(String dateStr)
Uses the current locale (user) to parse the date.
|
static Date |
parseDateTime(String dateStr)
Uses the current locale (user) to parse the date and time.
|
public static final String FORMAT_DATE_SHORT
public static final String FORMAT_DATE_MEDIUM
public static final String FORMAT_DATE_LONG
public static final String FORMAT_DATETIME_SHORT
public static final String FORMAT_DATETIME_MEDIUM
public static final String FORMAT_DATETIME_LONG
public static final String FORMAT_TIME_SHORT
public static final String FORMAT_TIME_MEDIUM
public static final String FORMAT_TIME_LONG
public static final String FORMAT_DEFAULTPATTERN
public static final String YYYY_MM_DD
public static final String YYYY_MM_DD_T_HH_MM_SS
public static final TimeZone UTC_TIME_ZONE
public static String format(Date date, String formatPattern)
public static String formatDateTime(Object val)
val
- Date or Calendarpublic static String formatDate(Object val)
val
- Date or Calendarpublic static Date parseDateTime(String dateStr) throws ParseException
dateStr
- Date or CalendarParseException
public static Date parseDate(String dateStr) throws ParseException
dateStr
- Date or CalendarParseException
public static Calendar getLocalCalendarFromUTC(Calendar utc)
public static Calendar getUTCCalendarFromDialogString(String dateString) throws ParseException
ParseException
public static Calendar getUTCCalendarFromLocalDate(Date date)
public static Calendar getCurrentUTCCalendar()
public static String createDateExpression(Calendar calendar)
public static String createDateTimeExpression(Calendar calendar)
Copyright © 2003–2019 Magnolia International Ltd.. All rights reserved.