public class Date extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ABBRDFS
1989/01/19 11:45:30.234
|
static String |
AMER
jan 19, 1983 11:45:30.234
|
static String |
AMERDATE
1/19/83 11:45:30.234
|
static String |
BINARY
758979930.234
|
static String |
CLUSTER
19-01-1989 11:45:30.234
|
static String |
CONVENTION
1989-01-19 11:45:30.234
|
static String |
DFS
1989-JAN-19 11:45:30.234
|
static String |
DOY
1983 303 11:45:30.234
|
static String |
EURO
19 jan 1983 11:45:30.234
|
static String |
EURODATE
19.1.83 11:45:30.234
|
static String |
HIGHLOW
83 01 19 00 11 45 30.234
|
static String |
ISEEDATE
83 019 JAN 19 11 45 30.234
|
static String |
ISO
19890119T114530.234
|
static String |
ISO8601
1989-01-19T11:45:30.234 or 1989-019T11:45:30.234 with omissions
|
static String |
JAPANDATE
83.1.19 11:45:30.234
|
static String |
NIPPONDATE
83.19.1 11:45:30.234
|
static 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(Calendar time,
double minutes)
Advances the time by a specified number of minutes.
|
static int |
compareTo(Calendar aTime,
Calendar anotherTime)
Compare a time to this instance for ordering.
|
static String |
convert(String date,
String toFormat,
String fromFormat)
Convert a date string in one format into another format.
|
static String |
elapsed(Calendar startTime)
Given a starting time calculated the elapsed time since and
for as a string.
|
static String |
findTimePattern(String name)
Returns the time format specification that matches the given
standard format name.
|
static 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 Calendar |
getCalendar(String date)
Parse a standard format time string into a Calendar object.
|
static String |
getDateFormat()
Get the current date format used for all date manipulation.
|
static String |
getDateString(Calendar cal)
Create a standard format time string for a Calendar
|
static String |
getDateString(Calendar cal,
String form)
Create a formated time string for a Calendar.
|
static String |
getDateString(Date date)
Create a standard format time string for a Date
|
static String |
getDateString(Date date,
String form)
Create a formated time string for a Date.
|
static String |
getDateString(long tick)
Create a standard format time string for a long (count of seconds).
|
static String |
getDateString(long tick,
String form)
Create a formated time string for a long (count of seconds).
|
static String |
getDateString(String date,
String form)
Parse a time string using parseISO8601() and create a formated time string.
|
static Calendar |
getDawn()
Sets the time to the earliest possible time.
|
static int |
getDaysInMonth(Calendar cal)
Determines the number of days in the month.
|
static Calendar |
getEternity()
Sets the time to the latest possible time.
|
static String |
getISO8601DateString(Calendar cal)
Create a standard ISO-8601 format time string for a Calendar.
|
static String |
getISO8601DateString(Date date)
Create a standard ISO-8601 format time string for a Date.
|
static String |
getISO8601DateString(long tick)
Create a standard ISO-8601 format time string for a long (count of seconds).
|
static String |
getISO8601DateString(String date)
Create a standard ISO-8601 format time string from a string.
|
static Calendar |
getNow()
Return a calendar object set to the current time.
|
static Calendar |
getTomorrow()
Return a calendar object set to the current time on tomorrow.
|
static Calendar |
interpret(String value)
Convert a string into a Calendar by intepreting the passed value.
|
static boolean |
isAfter(Calendar compareDate,
Calendar baseDate)
Checks if one time is on or after another time.
|
static boolean |
isAfter(String compareDate,
String baseDate)
Checks if one ISO8601 time is on or after another ISO8601 time.
|
static boolean |
isBefore(Calendar compareDate,
Calendar baseDate)
Checks if one time is on or before another time.
|
static boolean |
isBefore(String compareDate,
String baseDate)
Checks if one ISO8601 time is on or before another ISO8601 time.
|
static boolean |
isEmpty(String base)
Determines if a date string is "empty".
|
static boolean |
isInSpan(Calendar compare,
Calendar spanStart,
Calendar spanEnd)
Checks if a time is within a time span.
|
static boolean |
isInSpan(String compareStart,
String compareEnd,
String baseStart,
String baseEnd)
Checks if a start and end ISO-8601 time is within another start and end
ISO-8601 time.
|
static boolean |
isOnOrAfter(Calendar compareDate,
Calendar baseDate)
Checks if one time is on or after another time.
|
static boolean |
isOnOrAfter(String compareDate,
String baseDate)
Checks if one ISO-8601 time is on or after another ISO-8601 time.
|
static boolean |
isOnOrBefore(Calendar compareDate,
Calendar baseDate)
Checks if one time is on or before another time.
|
static boolean |
isOnOrBefore(String compareDate,
String baseDate)
Checks if one ISO8601 time is on or before another ISO8601 time.
|
static void |
main(String[] args)
Command-line interface
|
static String |
now()
Create a standard format time string for the current system time.
|
static Calendar |
parse(String value,
String pattern)
Parses a string into a Date using the given pattern.
|
static Calendar |
parseISO8601(String date)
Parses an ISO-8601 formatted time string.
|
static Calendar |
parseISO8601(String date,
Boolean ceil)
Parses an ISO-8601 formatted time string.
|
static Calendar |
parseISO8601Duration(String duration)
Parses an ISO-8601 formatted duration string.
|
static String |
sanitizeDate(String date)
Replaces any "T" which may appear in an ISO-8601 compliant date string
with a space.
|
static void |
setDateFormat(String dateFormat)
Sets the date format to use for all date manipulation.
|
static Calendar |
setLimit(Boolean ceil,
Calendar cal,
int field)
Set the maximum (ceil) or minimum (floor) value for a time field.
|
static long |
span(Calendar startTime,
Calendar endTime)
Returns the number of milliseconds between a time and this time.
|
static String |
translateISO8601Duration(String duration)
Parses an ISO-8601 formatted duration string and
describe it in human terms.
|
public static final String AMERDATE
public static final String EURODATE
public static final String AMER
public static final String EURO
public static final String DOY
public static final String JAPANDATE
public static final String NIPPONDATE
public static final String HIGHLOW
public static final String ISEEDATE
public static final String DFS
public static final String ABBRDFS
public static final String PDS
public static final String ISO
public static final String BINARY
public static final String CLUSTER
public static final String CONVENTION
public static final String ISO8601
public static void main(String[] args)
args
- the arguments passed on the command-line.public static String findTimePattern(String name)
name
- the name of the standard format.public static String now()
public static 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 String getDateString(Date date)
date
- a Date
set with the date and time.public static String getDateString(Calendar cal)
cal
- Calendar
set with the date and time.public static String getDateString(long tick, 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 String getDateString(Date date, String form)
date
- a Date
set with the date and time.form
- the pattern to format the date string. See SimpleDateFormat
.public static String getDateString(Calendar cal, String form)
cal
- Calendar
set with the date and time.form
- the pattern to format the date string. See SimpleDateFormat
.public static String getDateString(String date, String form)
date
- the date and time string in the ISO8601 format.form
- the pattern to format the date string. See SimpleDateFormat
.public static Calendar getCalendar(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 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 Calendar getNow()
Calendar
populated with the current date and time.public static Calendar getTomorrow()
Calendar
populated with the date and time 24 hours from the present.public static Calendar getDawn()
Calendar
set the earliest possible time.public static Calendar getEternity()
Calendar
set the latest possible time.public static String elapsed(Calendar startTime)
startTime
- a Calendar
containing a starting date and time.public static long span(Calendar startTime, Calendar endTime)
public static void advance(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(Calendar aTime, Calendar anotherTime)
aTime
- the Calendar
to compare to the base time.anotherTime
- the Calendar
to compare to the base time.public static 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 String getISO8601DateString(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 String getISO8601DateString(Calendar cal)
public static String getISO8601DateString(Date date)
public static String convert(String date, String toFormat, String fromFormat)
public static Calendar interpret(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 Calendar parse(String value, 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 Calendar parseISO8601Duration(String duration)
duration
- the string containing the ISO-8601 duration specfication.Calendar
set to the appropriate time.public static String translateISO8601Duration(String duration)
duration
- the string containing the ISO-8601 duration specfication.String
that describes the duration in human terms.public static Calendar parseISO8601(String date)
date
- the ISO-8601 time stirngCalendar
with set the appropriate date and time.public static Calendar parseISO8601(String date, Boolean ceil)
date
- the ISO-8601 time stirngceil
- 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 Calendar setLimit(Boolean ceil, 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(Calendar cal)
cal
- the Calendar with at least the year and month set.public static boolean isEmpty(String base)
base
- the time string to test.true
if the time string is empty, otherwise false
public static boolean isInSpan(String compareStart, String compareEnd, String baseStart, 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(Calendar compare, Calendar spanStart, 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(String compareDate, 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(Calendar compareDate, 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(String compareDate, 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(Calendar compareDate, 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(String compareDate, 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(Calendar compareDate, 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(String compareDate, String baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is beforethe baseDate, otherwise false
.public static boolean isBefore(Calendar compareDate, Calendar baseDate)
compareDate
- the date string to check.baseDate
- the reference date string.true
if the compareDate is beforethe baseDate, otherwise false
.public static String sanitizeDate(String date)
date
- a ISO-8601 time string.String
with the first "T" replaced with a space.public static void setDateFormat(String dateFormat)
dateFormat
- the date format to use as the "standard" format.
See SimpleDateFormat
for how to specify the date format.public static String getDateFormat()
Copyright © 2008-2009 Regents University of California. All Rights Reserved.