public final class DateTools extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ALT_ZVI |
static long |
ALT_ZVI_EPOCH |
static int |
COBOL |
static long |
COBOL_EPOCH |
static String |
FILENAME_FORMAT
Human readable timestamp filename string
|
static String |
ISO8601_FORMAT
ISO 8601 date output formatter without milliseconds.
|
static String |
ISO8601_FORMAT_MS
ISO 8601 date output formatter with milliseconds.
|
static int |
MICROSOFT |
static long |
MICROSOFT_EPOCH |
static String |
TIMESTAMP_FORMAT
Human readable timestamp string
|
static int |
UNIX
Timestamp formats.
|
static long |
UNIX_EPOCH
Milliseconds until UNIX epoch.
|
static int |
ZVI |
static long |
ZVI_EPOCH |
Modifier and Type | Method and Description |
---|---|
static String |
convertDate(long stamp,
int format)
Converts the given timestamp into an ISO8601 date.
|
static String |
convertDate(long stamp,
int format,
String outputFormat)
Converts the given timestamp into a date string with the given format.
|
static String |
convertDate(long stamp,
int format,
String outputFormat,
boolean correctTimeZoneForGMT)
Converts the given timestamp into a date string with the given format.
|
static String |
formatDate(String date,
String format)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String[] formats)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String[] formats,
boolean lenient)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String[] formats,
boolean lenient,
String separator)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String[] formats,
String separator)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String format,
boolean lenient)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String format,
boolean lenient,
String separator)
Formats the given date as an ISO 8601 date.
|
static String |
formatDate(String date,
String format,
String separator)
Formats the given date as an ISO 8601 date.
|
static String |
getFileTimestamp() |
static long |
getMillisFromTicks(long hi,
long lo)
Converts from two-word tick representation to milliseconds.
|
static long |
getTime(String date,
String format)
Converts a string date in the given format to a long timestamp
(in Unix format: milliseconds since January 1, 1970).
|
static long |
getTime(String date,
String format,
String separator)
Converts a string date in the given format to a long timestamp
(in Unix format: milliseconds since January 1, 1970) with special
milliseconds handling.
|
static String |
getTimestamp() |
protected static org.joda.time.Instant |
parseDate(String date,
String format,
String separator)
Parse the given date as a Joda instant
|
public static final int UNIX
public static final int COBOL
public static final int MICROSOFT
public static final int ZVI
public static final int ALT_ZVI
public static final long UNIX_EPOCH
public static final long COBOL_EPOCH
public static final long MICROSOFT_EPOCH
public static final long ZVI_EPOCH
public static final long ALT_ZVI_EPOCH
public static final String ISO8601_FORMAT_MS
public static final String ISO8601_FORMAT
public static final String TIMESTAMP_FORMAT
public static final String FILENAME_FORMAT
public static long getMillisFromTicks(long hi, long lo)
hi
- the upper 32 bits of the tick countlo
- the lower 32 bits of the tick countpublic static String convertDate(long stamp, int format)
stamp
- the format-dependent timestamp in millisecondsformat
- the format in which stamp
is stored.
This is used to select the epoch value used for normalizing
the timestamp to milliseconds since the UNIX epoch. Valid
values are #UNIX, #COBOL, #MICROSOFT, #ZVI, and #ALT_ZVI.UNIX_EPOCH
,
COBOL_EPOCH
,
MICROSOFT_EPOCH
,
ZVI_EPOCH
,
ALT_ZVI_EPOCH
public static String convertDate(long stamp, int format, String outputFormat)
stamp
- the format-dependent timestamp in millisecondsformat
- the format in which stamp
is stored.
This is used to select the epoch value used for normalizing
the timestamp to milliseconds since the UNIX epoch. Valid
values are #UNIX, #COBOL, #MICROSOFT, #ZVI, and #ALT_ZVI.outputFormat
- the pattern used for formatting the timestampUNIX_EPOCH
,
COBOL_EPOCH
,
MICROSOFT_EPOCH
,
ZVI_EPOCH
,
ALT_ZVI_EPOCH
,
DateTimeFormat
public static String convertDate(long stamp, int format, String outputFormat, boolean correctTimeZoneForGMT)
stamp
- the format-dependent timestamp in millisecondsformat
- the format in which stamp
is stored.
This is used to select the epoch value used for normalizing
the timestamp to milliseconds since the UNIX epoch. Valid
values are #UNIX, #COBOL, #MICROSOFT, #ZVI, and #ALT_ZVI.outputFormat
- the pattern used for formatting the timestampcorrectTimeZoneForGMT
- true if the timestamp is relative to GMTUNIX_EPOCH
,
COBOL_EPOCH
,
MICROSOFT_EPOCH
,
ZVI_EPOCH
,
ALT_ZVI_EPOCH
,
DateTimeFormat
protected static org.joda.time.Instant parseDate(String date, String format, String separator)
date
- The date to parse as a Joda timestampformat
- The date format to parse the string dateseparator
- The separator for millisecondsInstant
public static String formatDate(String date, String format)
formatDate(String, String, boolean)
, with the
lenient
flag set to false.date
- The date to format as ISO 8601format
- The date format to parse the string datepublic static String formatDate(String date, String format, String separator)
formatDate(String, String, boolean, String)
with the
lenient
flag set to false.date
- The date to format as ISO 8601format
- The date format to parse the string dateseparator
- The separator for millisecondspublic static String formatDate(String date, String format, boolean lenient)
date
- The date to format as ISO 8601.format
- The date format to parse the string datelenient
- Whether or not to leniently parse the date.public static String formatDate(String date, String format, boolean lenient, String separator)
date
- The date to format as ISO 8601format
- The date format to parse the string datelenient
- Whether or not to leniently parse the date.separator
- The separator for millisecondspublic static String formatDate(String date, String[] formats)
formatDate(String, String[], boolean, String)
with
lenient
set to false and separator
set to null.date
- The date to format as ISO 8601formats
- The date possible formats to parse the string datepublic static String formatDate(String date, String[] formats, boolean lenient)
formatDate(String, String[], boolean, String)
with
separator
set to null.date
- The date to format as ISO 8601.formats
- The date possible formats to parse the string datelenient
- Whether or not to leniently parse the date.public static String formatDate(String date, String[] formats, String separator)
formatDate(String, String[], boolean, String)
with
lenient
set to false.date
- The date to format as ISO 8601formats
- The date possible formats to parse the string dateseparator
- The separator for millisecondspublic static String formatDate(String date, String[] formats, boolean lenient, String separator)
date
- The date to format as ISO 8601.formats
- The date possible formats to parse the string datelenient
- Whether or not to leniently parse the date.separator
- The separator for millisecondspublic static long getTime(String date, String format)
date
- The date to convertformat
- The date format to parse the string datepublic static long getTime(String date, String format, String separator)
date
- The date to convertformat
- The date format to parse the string dateseparator
- The separator for millisecondspublic static String getTimestamp()
public static String getFileTimestamp()
Copyright © 2005–2019 Open Microscopy Environment. All rights reserved.