public class Date
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABBRDFS
1989/01/19 11:45:30.234
|
static java.lang.String |
AMER
jan 19, 1983 11:45:30.234
|
static java.lang.String |
AMERDATE
1/19/83 11:45:30.234
|
static java.lang.String |
BINARY
758979930.234
|
static java.lang.String |
CLUSTER
19-01-1989 11:45:30.234
|
static java.lang.String |
CONVENTION
1989-01-19 11:45:30.234
|
static java.lang.String |
DFS
1989-JAN-19 11:45:30.234
|
static java.lang.String |
DOY
1983 303 11:45:30.234
|
static java.lang.String |
EURO
19 jan 1983 11:45:30.234
|
static java.lang.String |
EURODATE
19.1.83 11:45:30.234
|
static java.lang.String |
HIGHLOW
83 01 19 00 11 45 30.234
|
static java.lang.String |
ISEEDATE
83 019 JAN 19 11 45 30.234
|
static java.lang.String |
ISO
1989-01-19T11:45:30.234
|
static java.lang.String |
ISO8601
1989-01-19T11:45:30.234 or 1989-019T11:45:30.234 with omissions
|
static java.lang.String |
JAPANDATE
83.1.19 11:45:30.234
|
static java.lang.String |
NIPPONDATE
83.19.1 11:45:30.234
|
static java.lang.String |
PACKEDISO
19890119T114530.234
|
static java.lang.String |
PDS
1989-01-19T11:45:30.234 or 1989-019T11:45:30.234 with omissions
|
Constructor and Description |
---|
Date() |
Modifier and Type | Method and Description |
---|---|
static void |
advance(java.util.Calendar time,
double minutes)
Advances the time by a specified number of minutes.
|
static int |
compareTo(java.util.Calendar aTime,
java.util.Calendar anotherTime)
Compare a time to this instance for ordering.
|
static java.lang.String |
convert(java.lang.String date,
java.lang.String toFormat,
java.lang.String fromFormat)
Convert a date string in one format into another format.
|
static java.lang.String |
elapsed(java.util.Calendar startTime)
Given a starting time calculated the elapsed time since and
for as a string.
|
static java.lang.String |
findTimePattern(java.lang.String name)
Returns the time format specification that matches the given
standard format name.
|
static java.util.Calendar |
getCalendar(long tick)
Create a Calendar based on a the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
|
static java.util.Calendar |
getCalendar(java.lang.String date)
Parse a standard format time string into a Calendar object.
|
static java.lang.String |
getDateFormat()
Get the current date format used for all date manipulation.
|
static java.lang.String |
getDateString(java.util.Calendar cal)
Create a standard format time string for a Calendar
|
static java.lang.String |
getDateString(java.util.Calendar cal,
java.lang.String form)
Create a formated time string for a Calendar.
|
static java.lang.String |
getDateString(java.util.Date date)
Create a standard format time string for a Date
|
static java.lang.String |
getDateString(java.util.Date date,
java.lang.String form)
Create a formated time string for a Date.
|
static java.lang.String |
getDateString(long tick)
Create a standard format time string for a long (count of seconds).
|
static java.lang.String |
getDateString(long tick,
java.lang.String form)
Create a formated time string for a long (count of seconds).
|
static java.lang.String |
getDateString(java.lang.String date,
java.lang.String form)
Parse a time string using parseISO8601() and create a formated time string.
|
static java.util.Calendar |
getDawn()
Sets the time to the earliest possible time.
|
static int |
getDaysInMonth(java.util.Calendar cal)
Determines the number of days in the month.
|
static java.util.Calendar |
getEternity()
Sets the time to the latest possible time.
|
static java.lang.String |
getISO8601DateString(java.util.Calendar cal)
Create a standard ISO-8601 format time string for a Calendar.
|
static java.lang.String |
getISO8601DateString(java.util.Date date)
Create a standard ISO-8601 format time string for a Date.
|
static java.lang.String |
getISO8601DateString(double tick)
Create a standard ISO-8601 format time string for a fractional count of seconds.
|
static java.lang.String |
getISO8601DateString(double tick,
java.util.Date epoch)
Create a standard ISO-8601 format time string for a fractional count of seconds.
|
static java.lang.String |
getISO8601DateString(long tick)
Create a standard ISO-8601 format time string for a long (count of milliseconds).
|
static java.lang.String |
getISO8601DateString(long tick,
java.util.Date epoch)
Create a standard ISO-8601 format time string for a long (count of milliseconds).
|
static java.lang.String |
getISO8601DateString(java.lang.String date)
Create a standard ISO-8601 format time string from a string.
|
static java.util.Calendar |
getNow()
Return a calendar object set to the current time.
|
static java.util.Calendar |
getTomorrow()
Return a calendar object set to the current time on tomorrow.
|
static java.util.Calendar |
interpret(java.lang.String value)
Convert a string into a Calendar by interpreting the passed value.
|
static boolean |
isAfter(java.util.Calendar compareDate,
java.util.Calendar baseDate)
Checks if one time is on or after another time.
|
static boolean |
isAfter(java.lang.String compareDate,
java.lang.String baseDate)
Checks if one ISO8601 time is on or after another ISO8601 time.
|
static boolean |
isBefore(java.util.Calendar compareDate,
java.util.Calendar baseDate)
Checks if one time is on or before another time.
|
static boolean |
isBefore(java.lang.String compareDate,
java.lang.String baseDate)
Checks if one ISO8601 time is on or before another ISO8601 time.
|
static boolean |
isEmpty(java.lang.String base)
Determines if a date string is "empty".
|
static boolean |
isInSpan(java.util.Calendar compare,
java.util.Calendar spanStart,
java.util.Calendar spanEnd)
Checks if a time is within a time span.
|
static boolean |
isInSpan(java.lang.String compareStart,
java.lang.String compareEnd,
java.lang.String baseStart,
java.lang.String baseEnd)
Checks if a start and end ISO-8601 time is within another start and end
ISO-8601 time.
|
static boolean |
isOnOrAfter(java.util.Calendar compareDate,
java.util.Calendar baseDate)
Checks if one time is on or after another time.
|
static boolean |
isOnOrAfter(java.lang.String compareDate,
java.lang.String baseDate)
Checks if one ISO-8601 time is on or after another ISO-8601 time.
|
static boolean |
isOnOrBefore(java.util.Calendar compareDate,
java.util.Calendar baseDate)
Checks if one time is on or before another time.
|
static boolean |
isOnOrBefore(java.lang.String compareDate,
java.lang.String baseDate)
Checks if one ISO8601 time is on or before another ISO8601 time.
|
static void |
main(java.lang.String[] args)
Command-line interface
|
static java.lang.String |
now()
Create a standard format time string for the current system time.
|
static java.lang.String |
now(java.lang.String form)
Create a standard format time string for the current system time.
|
static java.util.Calendar |
parse(java.lang.String value,
java.lang.String pattern)
Parses a string into a Date using the given pattern.
|
static java.util.Calendar |
parseISO8601(java.lang.String date)
Parses an ISO-8601 formatted time string.
|
static java.util.Calendar |
parseISO8601(java.lang.String date,
java.lang.Boolean ceil)
Parses an ISO-8601 formatted time string.
|
static java.util.Calendar |
parseISO8601Duration(java.lang.String duration)
Parses an ISO-8601 formatted duration string.
|
static java.lang.String |
removeZ(java.lang.String date)
Remove the ending "Z" from a time string, if present.
|
static java.lang.String |
sanitizeDate(java.lang.String date)
Replaces any "T" which may appear in an ISO-8601 compliant date string
with a space.
|
static void |
setDateFormat(java.lang.String dateFormat)
Sets the date format to use for all date manipulation.
|
static java.util.Calendar |
setLimit(java.lang.Boolean ceil,
java.util.Calendar cal,
int field)
Set the maximum (ceil) or minimum (floor) value for a time field.
|
static long |
span(java.util.Calendar startTime,
java.util.Calendar endTime)
Returns the number of milliseconds between a time and this time.
|
static java.lang.String |
translateISO8601Duration(java.lang.String duration)
Parses an ISO-8601 formatted duration string and
describe it in human terms.
|
public static final java.lang.String AMERDATE
public static final java.lang.String EURODATE
public static final java.lang.String AMER
public static final java.lang.String EURO
public static final java.lang.String DOY
public static final java.lang.String JAPANDATE
public static final java.lang.String NIPPONDATE
public static final java.lang.String HIGHLOW
public static final java.lang.String ISEEDATE
public static final java.lang.String DFS
public static final java.lang.String ABBRDFS
public static final java.lang.String PDS
public static final java.lang.String PACKEDISO
public static final java.lang.String ISO
public static final java.lang.String BINARY
public static final java.lang.String CLUSTER
public static final java.lang.String CONVENTION
public static final java.lang.String ISO8601
public static void main(java.lang.String[] args)
args
- the arguments passed on the command-line.public static java.lang.String findTimePattern(java.lang.String name)
name
- the name of the standard format.public static java.lang.String now()
public static java.lang.String now(java.lang.String form)
form
- the standard pattern to format the date string.public static java.lang.String getDateString(long tick)
tick
- the number of milliseconds since January 1, 1970, 00:00:00 GMT
not to exceed the milliseconds representation for the year 8099.
A negative number indicates the number of milliseconds before
January 1, 1970, 00:00:00 GMT.public static java.lang.String getDateString(java.util.Date date)
date
- a Date
set with the date and time.public static java.lang.String getDateString(java.util.Calendar cal)
cal
- Calendar
set with the date and time.public static java.lang.String getDateString(long tick, java.lang.String form)
tick
- the number of milliseconds since January 1, 1970, 00:00:00 GMT
not to exceed the milliseconds representation for the year 8099.
A negative number indicates the number of milliseconds before
January 1, 1970, 00:00:00 GMT.form
- the pattern to format the date string. See SimpleDateFormat
.public static java.lang.String getDateString(java.util.Date date, java.lang.String form)
date
- a Date
set with the date and time.form
- the pattern to format the date string. See SimpleDateFormat
.public static java.lang.String getDateString(java.util.Calendar cal, java.lang.String form)
cal
- Calendar
set with the date and time.form
- the pattern to format the date string. See SimpleDateFormat
.public static java.lang.String getDateString(java.lang.String date, java.lang.String form)
date
- the date and time string in the ISO8601 format.form
- the pattern to format the date string. See SimpleDateFormat
.public static java.util.Calendar getCalendar(java.lang.String date)
date
- the date and time string in the format yyyy-MM-dd HH:mm:ss.SSS.Calendar
populated with the date and time.public static java.util.Calendar getCalendar(long tick)
tick
- count of the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970).Calendar
populated with the date and time.public static java.util.Calendar getNow()
Calendar
populated with the current date and time.public static java.util.Calendar getTomorrow()
Calendar
populated with the date and time 24 hours from the present.public static java.util.Calendar getDawn()
Calendar
set the earliest possible time.public static java.util.Calendar getEternity()
Calendar
set the latest possible time.public static java.lang.String elapsed(java.util.Calendar startTime)
startTime
- a Calendar
containing a starting date and time.public static long span(java.util.Calendar startTime, java.util.Calendar endTime)
startTime
- a Calendar
containing a starting date and time.endTime
- a Calendar
containing a ending date and time.public static void advance(java.util.Calendar time, double minutes)
time
- the Calendar
containing the initial date and time.minutes
- the number of minutes to advance the time by.
The value may include a fractional minute.public static int compareTo(java.util.Calendar aTime, java.util.Calendar anotherTime)
aTime
- the Calendar
to compare to the base time.anotherTime
- the Calendar
to compare to the base time.public static java.lang.String getISO8601DateString(long tick, java.util.Date epoch)
tick
- the fractional number of seconds since the given epoch.epoch
- the Date representing the epoch for the tick.public static java.lang.String getISO8601DateString(long tick)
tick
- the number of milliseconds since January 1, 1970, 00:00:00 GMT
not to exceed the milliseconds representation for the year 8099.
A negative number indicates the number of milliseconds before
January 1, 1970, 00:00:00 GMT.public static java.lang.String getISO8601DateString(double tick)
tick
- the fractional number of seconds since January 1, 1970, 00:00:00 GMT
and cannot exceed the count for the year 8099.
A negative number indicates the number of seconds before
January 1, 1970, 00:00:00 GMT.public static java.lang.String getISO8601DateString(double tick, java.util.Date epoch)
tick
- the fractional number of seconds since the given epoch.epoch
- the Date representing the epoch for the tick.public static java.lang.String getISO8601DateString(java.lang.String date)
date
- the date and time string in any allowed abbreviated ISO8601 format time string.String
with the date and time formatted as an ISO-8601 time string of yyyy-MM-ddTHH:mm:ss.SSSZ.public static java.lang.String getISO8601DateString(java.util.Calendar cal)
cal
- Calendar
set with the date and time.String
with the date and time formatted as an ISO-8601 time string of yyyy-MM-ddTHH:mm:ss.SSSZ.public static java.lang.String getISO8601DateString(java.util.Date date)
date
- a Date
set with the date and time.String
with the date and time formatted as an ISO-8601 time string of yyyy-MM-ddTHH:mm:ss.SSSZ.public static java.lang.String convert(java.lang.String date, java.lang.String toFormat, java.lang.String fromFormat)
date
- a Date
set with the date and time.toFormat
- the desired output format.fromFormat
- the current format.String
with the date and time formatted as an ISO-8601 time string of yyyy-MM-ddTHH:mm:ss.SSSZ.public static java.util.Calendar interpret(java.lang.String value)
value
- the text containing the string to parse.Calendar
set the parsed time value, null if unable to parse the string.public static java.util.Calendar parse(java.lang.String value, java.lang.String pattern)
SimpleDateFormat
. The following patterns
are have special interpretation:
The following values have a special meaning (pattern is ignored):
value
- the text containing the string to parse.pattern
- the text containing the pattern to parse
buffer with.Calendar
set the parsed time value, null if unable to parse the string.public static java.util.Calendar parseISO8601Duration(java.lang.String duration)
duration
- the string containing the ISO-8601 duration specification.Calendar
set to the appropriate time.public static java.lang.String translateISO8601Duration(java.lang.String duration)
duration
- the string containing the ISO-8601 duration specification.String
that describes the duration in human terms.public static java.util.Calendar parseISO8601(java.lang.String date)
date
- the ISO-8601 time stirngCalendar
with set the appropriate date and time.public static java.util.Calendar parseISO8601(java.lang.String date, java.lang.Boolean ceil)
date
- the ISO-8601 time stringceil
- indicate if maximum value is assumed for non-specified parts.
If false
minimum (floor) value is assumed.Calendar
with set the appropriate date and time.public static java.util.Calendar setLimit(java.lang.Boolean ceil, java.util.Calendar cal, int field)
ceil
- indicate if maximum value is assumed for non-specified parts.
If false
minimum (floor) value is assumed.
cal the Calendar with higher order fields already set.
field the field to begin setting values.public static int getDaysInMonth(java.util.Calendar cal)
cal
- the Calendar with at least the year and month set.public static boolean isEmpty(java.lang.String base)
base
- the time string to test.true
if the time string is empty, otherwise false
public static boolean isInSpan(java.lang.String compareStart, java.lang.String compareEnd, java.lang.String baseStart, java.lang.String baseEnd)
compareStart
- the starting time of the first time range.compareEnd
- the ending time of the first time range.baseStart
- the starting time of the second time range.baseEnd
- the ending time of the second time range.true
if there is overlap of the two time ranges, otherwise false
.public static boolean isInSpan(java.util.Calendar compare, java.util.Calendar spanStart, java.util.Calendar spanEnd)
compare
- the starting time of the first time range.spanStart
- the starting time of the second time range.spanEnd
- the ending time of the second time range.true
if there is overlap of the two time ranges, otherwise false
.public static boolean isOnOrAfter(java.lang.String compareDate, java.lang.String baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is on or after the baseDate, otherwise false
.public static boolean isOnOrAfter(java.util.Calendar compareDate, java.util.Calendar baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is on or after the baseDate, otherwise false
.public static boolean isAfter(java.lang.String compareDate, java.lang.String baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is after the baseDate, otherwise false
.public static boolean isAfter(java.util.Calendar compareDate, java.util.Calendar baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is after the baseDate, otherwise false
.public static boolean isOnOrBefore(java.lang.String compareDate, java.lang.String baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is on or before the baseDate, otherwise false
.public static boolean isOnOrBefore(java.util.Calendar compareDate, java.util.Calendar baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is on or before the baseDate, otherwise false
.public static boolean isBefore(java.lang.String compareDate, java.lang.String baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is before the baseDate, otherwise false
.public static boolean isBefore(java.util.Calendar compareDate, java.util.Calendar baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is before the baseDate, otherwise false
.public static java.lang.String sanitizeDate(java.lang.String date)
date
- a ISO-8601 time string.String
with the first "T" replaced with a space.public static void setDateFormat(java.lang.String dateFormat)
dateFormat
- the date format to use as the "standard" format.
See SimpleDateFormat
for how to specify the date format.public static java.lang.String getDateFormat()
public static java.lang.String removeZ(java.lang.String date)
date
- the date string to checkCopyright © 2008-2018 Regents University of California. All Rights Reserved.