public class DateUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ATTIVIO_DATE_FORMAT
The format to for indexed Dates in Attivio
|
static TimeZone |
GMT
Time Zone for GMT
|
static String |
ISO_8601_DATE_FORMAT
The ISO-8601 date format: yyyy-MM-dd'T'HH:mm:ss.
|
static String |
ISO_8601_DATE_FORMAT_DAY_ONLY
The ISO-8601 date format for days only: yyyy-MM-dd
|
static String |
ISO_8601_DATE_FORMAT_NO_T
The ISO-8601 date format with no 'T': yyyy-MM-dd HH:mm:ss.
|
static String |
ISO_8601_DATE_FORMAT_WITH_MILLIS
The ISO-8601 date format including ms: yyyy-MM-dd'T'HH:mm:ss.
|
static TimeZone |
LOCAL
The local time zone
|
static TimeZone |
UTC
Time Zone for UTC
|
static String |
XML_GREGORIAN
The Gregorian date format: yyyy-MM-dd'T'HH:mm:ss.SSSZ.
|
static String |
XML_GREGORIAN_NO_MILLIS
The Gregorian date format: yyyy-MM-dd'T'HH:mm:ssZ.
|
Modifier | Constructor and Description |
---|---|
protected |
DateUtils()
The default constructor (hidden).
|
Modifier and Type | Method and Description |
---|---|
static Date |
ceil(TimeResolution units,
Date value)
Round
value up to the next units . |
static String |
formatDate(Date d)
Formats a date according to ISO_8601_DATE_FORMAT format.
|
static String |
formatDate(Date d,
String format,
String timeZone)
Formats a date according to a specified format.
|
static String |
formatDate(Date d,
String format,
TimeZone timeZone)
Formats a date according to a specified format.
|
static String |
formatDate(Date d,
TimeZone timezone)
Formats a date according to ISO_8601_DATE_FORMAT format.
|
static String |
formatDuration(long time)
Formats a duration ( difference between 2 times) such that
only the 2 most significant time units are included.
|
static TimeZone |
getTimeZone(String tzString)
Converts the string passed in
tzString to a java.util.TimeZone |
static Date |
parseDate(String s)
Parses a date in ISO_8601_DATE_FORMAT format.
|
static Date |
parseDate(String dateStr,
String format,
TimeZone timeZone)
Parses a date in the specified format format.
|
static Date |
parseDate(String s,
TimeZone timeZone)
Parse a date in ISO_8601_DATE_FORMAT in the specified time zone.
|
static String |
timeDifference(long start,
long stop)
Returns the time broken down by hour, minute, second.
|
static Calendar |
toCalendar(Date date)
Convert a Date to a Calendar.
|
static Calendar |
toCalendar(Date date,
TimeZone zone)
Convert a Date to a Calendar using a time zone.
|
static Date |
toDate(Object o)
Converts an arbitrary object into a Date.
|
static Date |
toDate(Object o,
String formatString)
Converts an arbitrary object into a Date based on a format string.
|
static Date |
toDate(Object o,
String formatString,
TimeZone defaultTimezone)
Converts an arbitrary object into a Date based on a format string and timezone default.
|
public static final String ISO_8601_DATE_FORMAT
public static final String ISO_8601_DATE_FORMAT_WITH_MILLIS
public static final String ISO_8601_DATE_FORMAT_DAY_ONLY
public static final String ISO_8601_DATE_FORMAT_NO_T
public static final String XML_GREGORIAN_NO_MILLIS
public static final String XML_GREGORIAN
public static final String ATTIVIO_DATE_FORMAT
public static final TimeZone UTC
public static final TimeZone GMT
public static final TimeZone LOCAL
public static Calendar toCalendar(Date date, TimeZone zone)
public static String formatDate(Date d, String format, String timeZone)
d
- Date to formatformat
- format stringtimeZone
- the name of the TimeZone to use for formattingpublic static String formatDate(Date d, String format, TimeZone timeZone)
d
- Date to formatformat
- format stringtimeZone
- the TimeZone to use for formattingpublic static Date parseDate(String s)
s
- Date string to parse in ISO_8601_DATE_FORMAT formatAttivioDateFormat.parse(String)
public static Date parseDate(String s, TimeZone timeZone)
public static Date parseDate(String dateStr, String format, TimeZone timeZone) throws ParseException
dateStr
- Date string to parseformat
- format to parse Date astimeZone
- the timezone to parse dateStr asParseException
- if the date is not in the expected formatpublic static String formatDate(Date d)
d
- Date to formatpublic static String formatDate(Date d, TimeZone timezone)
d
- Date to formattimezone
- timezone to format topublic static String formatDuration(long time)
time
- duration. (in milliseconds)public static Date toDate(Object o, String formatString)
o
- the object to convertformatString
- the formatpublic static Date toDate(Object o, String formatString, TimeZone defaultTimezone)
o
- the object to convertformatString
- the formatdefaultTimezone
- the fallback timezone in case the format specified doesn't contain a timezonepublic static Date toDate(Object o)
o
- the objectpublic static TimeZone getTimeZone(String tzString)
tzString
to a java.util.TimeZone
tzString
- the timezone stringTimeZone
object or null if tzString
is not a valid/known timezonepublic static final Date ceil(TimeResolution units, Date value)
value
up to the next units
.public static String timeDifference(long start, long stop)
Copyright © 2018 Attivio, Inc. All Rights Reserved.
PATENT NOTICE: Attivio, Inc. Software Related Patents. With respect to the Attivio software product(s) being used, the following patents apply: Querying Joined Data Within A Search Engine Index: United States Patent No.(s): 8,073,840. Ordered Processing of Groups of Messages: U.S. Patent No.(s) 8,495,656. Signal processing approach to sentiment analysis for entities in documents: U.S. Patent No.(s) 8,725,494. Other U.S. and International Patents Pending.