|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cohort.util.Calendar2
public class Calendar2
This class has static methods for dealing with dates and times.
newGCalendar only accounts for daylight savings if your computer is correctly set up. E.g., in Windows, make sure "Start : Control Panel : Date and Time : Time Zone : Automatically adjust clock for daylight savings changes" is checked. Otherwise, the TimeZone used by GregorianCalendar will be for standard time (not including daylight savings time, if any).
Comments about working with Java's GregorianCalendar class:
But this class seeks to simplify things to the more common cases of parsing and formatting using the same time zone as the GregorianCalendar class, and offering GregorianCalendar constructors for Local (with daylight savings if that is what your area does) and Zulu (aka GMT and UTC, which doesn't ever use daylight savings).
A summary of ISO 8601 Date Time formats is at http://www.cl.cam.ac.uk/~mgk25/iso-time.html and http://www.iso.org/iso/date_and_time_format and years B.C at http://www.tondering.dk/claus/cal/node4.html#SECTION00450000000000000000
Calendar2 does not use ERA designations. It uses negative year values for B.C years (calendar2Year = 1 - BCYear). Note that BCYears are 1..., so 1 BC is calendar2Year 0 (or 0000), and 2 BC is calendar2Year -1 (or -0001).
| Field Summary | |
|---|---|
static int |
AM_PM
|
static int |
BC
|
static int |
DATE
|
static int |
DAY_OF_YEAR
|
static int |
DST_OFFSET
|
static int |
ERA
|
static int |
HOUR
|
static int |
HOUR_OF_DAY
|
static java.lang.String[] |
IDEAL_N_OPTIONS
The IDEAL values are used for makeIdealGC. |
static int[] |
IDEAL_UNITS_FIELD
|
static java.lang.String[] |
IDEAL_UNITS_OPTIONS
|
static double[] |
IDEAL_UNITS_SECONDS
|
static long |
MILLIS_PER_DAY
|
static long |
MILLIS_PER_HOUR
|
static long |
MILLIS_PER_MINUTE
|
static int |
MILLISECOND
|
static int |
MINUTE
|
static int |
MONTH
|
static boolean |
reallyVerbose
Set this to true (by calling reallyVerbose=true in your program, not but changing the code here) if you want lots of diagnostic messages sent to String2.log. |
static int |
SECOND
|
static int |
SECONDS_PER_DAY
|
static int |
SECONDS_PER_HOUR
|
static int |
SECONDS_PER_MINUTE
|
static java.lang.String |
SECONDS_SINCE_1970
|
static boolean |
verbose
Set this to true (by calling verbose=true in your program, not but changing the code here) if you want lots of diagnostic messages sent to String2.log. |
static int |
YEAR
|
static int |
ZONE_OFFSET
|
static java.util.TimeZone |
zuluTimeZone
|
| Constructor Summary | |
|---|---|
Calendar2()
|
|
| Method Summary | |
|---|---|
static double |
backNDays(int nDays,
double max)
This returns the start of a day, n days back from max (or from now if max=NaN). |
static int |
binaryFindClosest(java.lang.String[] isoDates,
java.lang.String timeValue)
Find the closest match for timeValue in isoDates which must be sorted in ascending order. |
static int |
binaryFindFirstGE(java.lang.String[] isoDates,
java.lang.String timeValue)
Find the first element which is >= timeValue in isoDates (sorted ascending. |
static int |
binaryFindLastLE(java.lang.String[] isoDates,
java.lang.String timeValue)
Find the last element which is <= timeValue in isoDates (sorted ascending). |
static java.util.GregorianCalendar |
centerOfMonth(java.util.GregorianCalendar gc)
This converts the date, hour, minute, second so gc is at the exact center of its current month. |
static java.util.GregorianCalendar |
clearSmallerFields(java.util.GregorianCalendar gc,
int field)
This clears the fields smaller than 'field' (e.g., HOUR_OF_DAY clears MINUTE, SECOND, and MILLISECOND, but not HOUR_OF_DAY, MONTH, or YEAR). |
static java.lang.String |
elapsedTimeString(double millis)
This converts a millis elapsed time value (139872234 ms or 783 ms) to a nice string (e.g., "7h 4m 5s", "5.783 s", or "783 ms"). |
static java.lang.String |
epochHoursToIsoString(int hours)
This converts hours since 1970-01-01T00:00:00Z to an ISO Zulu dateTime String 'T'. |
static java.util.GregorianCalendar |
epochSecondsToGc(double seconds)
This converts seconds since 1970-01-01T00:00:00Z to a GregorianCalendar. |
static java.lang.String |
epochSecondsToIsoStringSpace(double seconds)
This converts seconds since 1970-01-01T00:00:00Z to an ISO Zulu dateTime String with space. |
static java.lang.String |
epochSecondsToIsoStringT(double seconds)
This converts seconds since 1970-01-01T00:00:00Z to an ISO Zulu dateTime String with 'T'. |
static double |
epochSecondsToUnitsSince(double baseSeconds,
double factorToGetSeconds,
double epochSeconds)
This converts an epochSeconds value into a unitsSince value. |
static double |
factorToGetSeconds(java.lang.String units)
This returns the factor to multiply by 'units' data to get seconds data (e.g., "minutes" returns 60). |
static java.lang.String |
fieldName(int field)
For diagnostic purposes, this returns the name of one of the fields defined above (or "unknown_field"). |
static java.lang.String |
formatAsCompactDateTime(java.util.GregorianCalendar gc)
This returns a compact formatted [-]YYYYMMDDHHMMSS string e.g., "20040102030405" using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsDDMonYYYY(java.util.GregorianCalendar gc)
This returns a DD-Mon-[-]YYYY string e.g., "31-Jul-2004 00:00:00" using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsISODate(java.util.GregorianCalendar gc)
This returns a ISO-style formatted date string e.g., "2004-01-02" using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsIsoDateHM(java.util.GregorianCalendar gc)
This returns a partial ISO-style formatted [-]YYYY-MM-DD HH:MM string e.g., "2004-01-02 03:04" using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsISODateTimeSpace(java.util.GregorianCalendar gc)
This converts a GregorianCalendar object into an ISO-format dateTime string (with space separator: [-]YYYY-MM-DD HH:MM:SS) using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsISODateTimeT(java.util.GregorianCalendar gc)
This converts a GregorianCalendar object into an ISO-format dateTime string (with 'T' separator: [-]YYYY-MM-DDTHH:MM:SS) using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsISOYear(java.util.GregorianCalendar gc)
This returns the year as YYYY. |
static java.lang.String |
formatAsRFC822GMT(java.util.GregorianCalendar gc)
This returns an RFC 822 format date time string ("Sun, 06 Nov 1994 08:49:37 GMT"). |
static java.lang.String |
formatAsUSSlash24(java.util.GregorianCalendar gc)
This returns a US-style slash format date 24-hour time string ("1/20/2006 21:00:00") (commonly used by Microsoft Access). |
static java.lang.String |
formatAsUSSlashAmPm(java.util.GregorianCalendar gc)
This returns a US-style slash format date time string ("1/20/2006 9:00:00 pm"). |
static java.lang.String |
formatAsYYYYDDD(java.util.GregorianCalendar gc)
This returns a [-]YYYYDDD string e.g., "2004001" using its current get() values (not influenced by the format's timeZone). |
static java.lang.String |
formatAsYYYYMM(java.util.GregorianCalendar gc)
This returns a [-]YYYYMM string e.g., "200401" using its current get() values (not influenced by the format's timeZone). |
static double |
gcToEpochSeconds(java.util.GregorianCalendar gc)
This converts a GregorianCalendar to seconds since 1970-01-01T00:00:00Z. |
static java.lang.String |
getCurrentISODateStringLocal()
This returns the current local date in ISO format. |
static java.lang.String |
getCurrentISODateStringZulu()
This returns the current Zulu date in ISO format. |
static java.lang.String |
getCurrentISODateTimeStringLocal()
This returns the current local dateTime in ISO T format. |
static java.lang.String |
getCurrentISODateTimeStringZulu()
This returns the current Zulu dateTime in ISO T format. |
static java.lang.String |
getCurrentRFC822Zulu()
This returns the current Zulu date in RFC 822 format. |
static java.lang.String |
getMonthName(int month)
This returns the full month name (e.g., "January"). |
static java.lang.String |
getMonthName3(int month)
This returns a 3 character month name (eg. |
static double[] |
getNEvenlySpaced(double start,
double stop,
int maxNValues)
This returns a double[] of maxNValues (or fewer) evenly spaced, between start and stop. |
static java.lang.String |
getParseErrorString(java.lang.String s,
java.lang.Exception e)
This returns an error message indicating that the specified isoDateString couldn't be parsed. |
static double[] |
getTimeBaseAndFactor(java.lang.String tsUnits)
This converts a string "[units] since [isoDate]" (e.g., "minutes since 1985-01-01") into a baseSeconds (seconds since 1970-01-01) and a factor ("minutes" returns 60). |
static int |
getYear(java.util.GregorianCalendar gc)
This returns the year. |
static boolean |
isIsoDate(java.lang.String s)
This returns true if the string appears to be an ISO date/time (matching YYYY-MM...). |
static java.util.GregorianCalendar |
isoDateTimeAdd(java.lang.String isoDate,
int n,
int field)
This adds the specified n field's to the isoDate, and returns the resulting GregorianCalendar object. |
static int |
isoStringToEpochHours(java.lang.String isoZuluString)
This converts an ISO Zulu dateTime String to hours since 1970-01-01T00:00:00Z, rounded to the nearest hour. |
static double |
isoStringToEpochSeconds(java.lang.String isoZuluString)
This converts an ISO Zulu dateTime String to seconds since 1970-01-01T00:00:00Z, rounded to the nearest milli, then remove millis. |
static long |
isoZuluStringToMillis(java.lang.String s)
This converts an ISO Zulu DateTime string to millis since 1970-01-01T00:00:00Z. |
static java.lang.String |
millisToIsoZuluString(long millis)
This converts millis since 1970-01-01T00:00:00Z to an ISO Zulu DateTime string. |
static java.util.GregorianCalendar |
newGCalendarLocal()
This returns a gregorianCalendar object which has the correct current time (e.g., wall clock time, for the local time zone, which includes daylight savings, if applicable) and the local time zone. |
static java.util.GregorianCalendar |
newGCalendarLocal(int year,
int dayOfYear)
Get a GregorianCalendar object (local time zone) for the specified time. |
static java.util.GregorianCalendar |
newGCalendarLocal(int year,
int month,
int dayOfMonth)
Get a GregorianCalendar object (local time zone) for the specified. |
static java.util.GregorianCalendar |
newGCalendarLocal(int year,
int month,
int dayOfMonth,
int hour,
int minute,
int second,
int millis)
Get a GregorianCalendar object (local time zone) for the specified time. |
static java.util.GregorianCalendar |
newGCalendarZulu()
Get a GregorianCalendar object with the current UTC (A.K.A., GMT or Zulu) time and a UTC time zone. |
static java.util.GregorianCalendar |
newGCalendarZulu(int year,
int dayOfYear)
Get a GregorianCalendar object (Zulu time zone) for the specified time. |
static java.util.GregorianCalendar |
newGCalendarZulu(int year,
int month,
int dayOfMonth)
Get a GregorianCalendar object (Zulu time zone) for the specified time. |
static java.util.GregorianCalendar |
newGCalendarZulu(int year,
int month,
int dayOfMonth,
int hour,
int minute,
int second,
int millis)
Get a GregorianCalendar object (Zulu time zone) for the specified time. |
static java.util.GregorianCalendar |
newGCalendarZulu(long millis)
Get a GregorianCalendar object with the specified millis time (UTC) and a UTC time zone. |
static int |
nextNice(double d,
int[] nice)
This returns the value in nice which is >= d, or a multiple of the last value which is higher than d. |
static java.util.GregorianCalendar |
parseCompactDateTime(java.util.GregorianCalendar gc,
java.lang.String s)
This converts compact string (must be [-]YYYYMMDD, [-]YYYYMMDDhh, [-]YYYYMMDDhhmm, or [-]YYYYMMDDhhmmss) into a GregorianCalendar object. |
static java.util.GregorianCalendar |
parseCompactDateTimeZulu(java.lang.String s)
This is like parseCompactDateTime, but assumes the time zone is Zulu. |
static java.util.GregorianCalendar |
parseDDMonYYYY(java.util.GregorianCalendar gc,
java.lang.String s)
This converts a DD-Mon-[-]YYYY string e.g., "31-Jul-2004 00:00:00" into a GregorianCalendar object. |
static java.util.GregorianCalendar |
parseDDMonYYYYZulu(java.lang.String s)
This is like parseDDMonYYYY, but assumes the time zone is Zulu. |
static java.util.GregorianCalendar |
parseISODateTime(java.util.GregorianCalendar gc,
java.lang.String s)
This converts an ISO date time string ([-]YYYY-MM-DDTHH:MM:SS.SS±ZZ:ZZ) into a GregorianCalendar object. |
static java.util.GregorianCalendar |
parseISODateTimeZulu(java.lang.String s)
This converts an ISO *ZULU* date time string ([-]YYYY-MM-DDTHH:MM:SS±ZZ:ZZ) into a GregorianCalendar object. |
static java.util.GregorianCalendar |
parseUSSlash24(java.util.GregorianCalendar gc,
java.lang.String s)
This converts a US slash 24 hour string ("1/20/2006" or "1/20/2006 14:23:59") (commonly used by Microsoft Access) into a GregorianCalendar object. |
static java.util.GregorianCalendar |
parseUSSlash24Zulu(java.lang.String s)
This is like parseUSSlash24, but assumes the time zone is Zulu. |
static java.util.GregorianCalendar |
parseYYYYDDD(java.util.GregorianCalendar gc,
java.lang.String s)
This converts a [-]YYYYDDD string into a GregorianCalendar object. |
static java.util.GregorianCalendar |
parseYYYYDDDZulu(java.lang.String s)
This is like parseYYYYDDD, but assumes the time zone is Zulu. |
static java.lang.String |
removeSpacesDashesColons(java.lang.String s)
Remove any spaces, dashes (except optional initial dash), colons, and T's from s. |
static java.util.GregorianCalendar |
roundToIdealGC(double epochSeconds,
int idealN,
int idealUnits)
This rounds to the nearest idealN, idealUnits (e.g., 2 months) (starting at Jan 1, 0000). |
static java.lang.String |
safeEpochSecondsToIsoStringT(double seconds,
java.lang.String NaNString)
This is like epochSecondsToIsoStringT, but returns NaNString if seconds is NaN. |
static java.lang.String |
safeEpochSecondsToIsoStringTZ(double seconds,
java.lang.String NaNString)
This is like epochSecondsToIsoStringT, but add "Z" at end of time, and returns NaNString if seconds is NaN.. |
static double |
safeIsoStringToEpochSeconds(java.lang.String isoZuluString)
This is like isoStringToEpochSeconds, but returns NaN if trouble. |
static double |
unitsSinceToEpochSeconds(double baseSeconds,
double factorToGetSeconds,
double unitsSince)
This converts a unitsSince value into epochSeconds. |
static java.lang.String |
yyyydddToIsoDate(java.lang.String s)
Convert a String with [-]yyyyddd to a String with YYYY-mm-dd. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ERA
public static final int BC
public static final int YEAR
public static final int MONTH
public static final int DATE
public static final int DAY_OF_YEAR
public static final int HOUR
public static final int HOUR_OF_DAY
public static final int MINUTE
public static final int SECOND
public static final int MILLISECOND
public static final int AM_PM
public static final int ZONE_OFFSET
public static final int DST_OFFSET
public static final int SECONDS_PER_MINUTE
public static final int SECONDS_PER_HOUR
public static final int SECONDS_PER_DAY
public static final long MILLIS_PER_MINUTE
public static final long MILLIS_PER_HOUR
public static final long MILLIS_PER_DAY
public static final java.lang.String SECONDS_SINCE_1970
public static final java.util.TimeZone zuluTimeZone
public static java.lang.String[] IDEAL_N_OPTIONS
public static java.lang.String[] IDEAL_UNITS_OPTIONS
public static double[] IDEAL_UNITS_SECONDS
public static int[] IDEAL_UNITS_FIELD
public static boolean verbose
public static boolean reallyVerbose
| Constructor Detail |
|---|
public Calendar2()
| Method Detail |
|---|
public static java.lang.String fieldName(int field)
field -
public static double[] getTimeBaseAndFactor(java.lang.String tsUnits)
throws java.lang.Exception
WARNING: don't use the equations above. Use unitsSinceToEpochSeconds or epochSecondsToUnitsSince which correctly handle special cases.
tsUnits - e.g., "minutes since 1985-01-01"
java.lang.Exception - if trouble (tsUnits is null or invalid)
public static double unitsSinceToEpochSeconds(double baseSeconds,
double factorToGetSeconds,
double unitsSince)
baseSeconds - factorToGetSeconds - unitsSince -
public static double epochSecondsToUnitsSince(double baseSeconds,
double factorToGetSeconds,
double epochSeconds)
baseSeconds - factorToGetSeconds - epochSeconds -
public static double factorToGetSeconds(java.lang.String units)
throws java.lang.Exception
units -
java.lang.Exception - if trouble (e.g., units is null or not an expected value)public static double isoStringToEpochSeconds(java.lang.String isoZuluString)
isoZuluString -
exception - if trouble (e.g., input is null or invalid format)public static double safeIsoStringToEpochSeconds(java.lang.String isoZuluString)
public static boolean isIsoDate(java.lang.String s)
s -
public static double gcToEpochSeconds(java.util.GregorianCalendar gc)
gc -
exception - if trouble (e.g., gc is null)public static java.util.GregorianCalendar epochSecondsToGc(double seconds)
seconds - (including fractional seconds)
exception - if trouble (e.g., seconds is NaN)public static int isoStringToEpochHours(java.lang.String isoZuluString)
isoZuluString -
java.lang.Exception - if trouble (e.g., input is null or invalid format)public static java.lang.String epochSecondsToIsoStringT(double seconds)
seconds - with optional fractional part
java.lang.Exception - if trouble (e.g., seconds is NaN)
public static java.lang.String safeEpochSecondsToIsoStringT(double seconds,
java.lang.String NaNString)
public static java.lang.String safeEpochSecondsToIsoStringTZ(double seconds,
java.lang.String NaNString)
public static java.lang.String epochSecondsToIsoStringSpace(double seconds)
seconds - with optional fractional part
java.lang.Exception - if trouble (e.g., seconds is NaN)public static java.lang.String epochHoursToIsoString(int hours)
hours -
java.lang.Exception - if trouble (e.g., hours is Integer.MAX_VALUE)public static java.lang.String getMonthName3(int month)
month - 1..12
java.lang.Exception - if month is out of rangepublic static java.lang.String getMonthName(int month)
month - 1..12
java.lang.Exception - if month is out of rangepublic static java.util.GregorianCalendar newGCalendarLocal()
public static java.util.GregorianCalendar newGCalendarZulu()
public static java.util.GregorianCalendar newGCalendarZulu(long millis)
java.lang.Exception - if trouble (e.g., millis == Long.MAX_VALUE)
public static java.util.GregorianCalendar newGCalendarLocal(int year,
int month,
int dayOfMonth)
year - (e.g., 2005)month - (1..12) (this is consciously different than Java's standard)dayOfMonth - (1..31)
java.lang.Exception - if trouble (e.g., year is Integer.MAX_VALUE)
public static java.util.GregorianCalendar newGCalendarZulu(int year,
int month,
int dayOfMonth)
year - (e.g., 2005)month - (1..12) (this is consciously different than Java's standard)dayOfMonth - (1..31)
java.lang.Exception - if trouble (e.g., year is Integer.MAX_VALUE)
public static java.util.GregorianCalendar newGCalendarLocal(int year,
int month,
int dayOfMonth,
int hour,
int minute,
int second,
int millis)
year - (e.g., 2005)month - (1..12) (this is consciously different than Java's standard)dayOfMonth - (1..31)hour - (0..23)minute - (0..59)second - (0..59)millis - (0..999)
java.lang.Exception - if trouble (e.g., year is Integer.MAX_VALUE)
public static java.util.GregorianCalendar newGCalendarZulu(int year,
int month,
int dayOfMonth,
int hour,
int minute,
int second,
int millis)
year - (e.g., 2005)month - (1..12) (this is consciously different than Java's standard)dayOfMonth - (1..31)hour - (0..23)minute - (0..59)second - (0..59)millis - (0..999)
java.lang.Exception - if trouble (e.g., year is Integer.MAX_VALUE)
public static java.util.GregorianCalendar newGCalendarLocal(int year,
int dayOfYear)
year - (e.g., 2005)dayOfYear - (usually 1..365, but 1..366 in leap years)
java.lang.Exception - if trouble (e.g., year is Integer.MAX_VALUE)
public static java.util.GregorianCalendar newGCalendarZulu(int year,
int dayOfYear)
year - (e.g., 2005)dayOfYear - (usually 1..365, but 1..366 in leap years)
java.lang.Exception - if trouble (e.g., year is Integer.MAX_VALUE)public static int getYear(java.util.GregorianCalendar gc)
gc -
public static java.lang.String formatAsISOYear(java.util.GregorianCalendar gc)
gc -
public static java.lang.String formatAsISODate(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsISODateTimeT(java.util.GregorianCalendar gc)
gc -
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsISODateTimeSpace(java.util.GregorianCalendar gc)
gc -
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsIsoDateHM(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsCompactDateTime(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsYYYYDDD(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsYYYYMM(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsDDMonYYYY(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsUSSlashAmPm(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsRFC822GMT(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in the gc's time zone (which should always be GMT because "GMT" is put at the end).
java.lang.Exception - if trouble (e.g., gc is null)public static java.lang.String formatAsUSSlash24(java.util.GregorianCalendar gc)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.
java.lang.Exception - if trouble (e.g., gc is null)
public static java.util.GregorianCalendar parseISODateTime(java.util.GregorianCalendar gc,
java.lang.String s)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.
Timezone info is relative to the gc's time zone.s - the dateTimeString in the ISO format (YYYY-MM-DDTHH:MM:SS±ZZ:ZZ
or -YYYY-MM-DDTHH:MM:SS±ZZ:ZZ for years B.C.)
For years B.C., use calendar2Year = 1 - BCYear.
Note that BCYears are 1..., so 1 BC is calendar2Year 0 (or 0000),
and 2 BC is calendar2Year -1 (or -0001).
java.lang.Exception - if trouble (e.g., gc is null or s is null or
not at least #)public static java.util.GregorianCalendar parseISODateTimeZulu(java.lang.String s)
s - the dateTimeString in the ISO format ([-]YYYY-MM-DDTHH:MM:SS)
java.lang.Exception - if trouble (e.g., s is null or not at least #)
public static java.util.GregorianCalendar parseUSSlash24(java.util.GregorianCalendar gc,
java.lang.String s)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.s - the dateString in the US slash format ("1/20/2006" or
"1/20/2006 14:23:59")
java.lang.Exception - if trouble (e.g., gc is null or s is null or not at least #/#/#)public static java.util.GregorianCalendar parseUSSlash24Zulu(java.lang.String s)
java.lang.Exception - if trouble (e.g., s is null or not at least #/#/#)
public static java.util.GregorianCalendar parseCompactDateTime(java.util.GregorianCalendar gc,
java.lang.String s)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.s - dateTimeString in compact format (must be [-]YYYYMMDD, [-]YYYYMMDDhh,
[-]YYYYMMDDhhmm, or [-]YYYYMMDDhhmmss)
java.lang.Exception - if trouble (e.g., gc is null or s is null or not at least
YYYYMMDD)public static java.util.GregorianCalendar parseCompactDateTimeZulu(java.lang.String s)
java.lang.Exception - if trouble (e.g., s is null or invalid)
public static java.util.GregorianCalendar parseDDMonYYYY(java.util.GregorianCalendar gc,
java.lang.String s)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.s - dateTimeString in YYYYDDD format
java.lang.Exception - if trouble (e.g., gc is null or s is null or not
DDMonYYYY)public static java.util.GregorianCalendar parseDDMonYYYYZulu(java.lang.String s)
java.lang.Exception - if trouble (e.g., s is null or invalid)
public static java.util.GregorianCalendar parseYYYYDDD(java.util.GregorianCalendar gc,
java.lang.String s)
gc - a GregorianCalendar object. The dateTime will be interpreted
as being in gc's time zone.s - dateTimeString in YYYYDDD format
java.lang.Exception - if trouble (e.g., gc is null or s is null or not
YYYYDDDD)public static java.util.GregorianCalendar parseYYYYDDDZulu(java.lang.String s)
java.lang.Exception - if trouble (e.g., s is null or not YYYYDDD)
public static java.lang.String getParseErrorString(java.lang.String s,
java.lang.Exception e)
s - dateTimeStringe - a Exception
public static java.lang.String yyyydddToIsoDate(java.lang.String s)
s - a String with a date in the form yyyyddd
java.lang.Exception - if trouble (e.g., s is null or not YYYYDDD)public static java.lang.String getCurrentISODateTimeStringLocal()
public static java.lang.String getCurrentISODateTimeStringZulu()
public static java.lang.String getCurrentRFC822Zulu()
public static java.lang.String getCurrentISODateStringZulu()
public static java.lang.String getCurrentISODateStringLocal()
public static long isoZuluStringToMillis(java.lang.String s)
s - the ISO Zulu DateTime string
java.lang.Exception - if trouble (e.g., s is null or not at least #)public static java.lang.String millisToIsoZuluString(long millis)
millis - the millis since 1970-01-01T00:00:00Z
java.lang.Exception - if trouble (e.g., millis is Long.MAX_VALUE)public static java.lang.String removeSpacesDashesColons(java.lang.String s)
s - a string
java.lang.Exception - if trouble (e.g., s is null)
public static int binaryFindClosest(java.lang.String[] isoDates,
java.lang.String timeValue)
This throws RuntimeException if some years are negative (0000 is ok).
isoDates - is an ascending sorted list of ISO dates [times].
It the array has duplicates and timeValue equals one of them,
it isn't specified which duplicate's index will be returned.timeValue - the ISO timeValue to be matched
(with connector "T" or " " matching the isoDates)
public static int binaryFindLastLE(java.lang.String[] isoDates,
java.lang.String timeValue)
If firstGE > lastLE, there are no matching elements (because the requested range is less than or greater than all the values, or between two adjacent values).
This throws RuntimeException if some years are negative (0000 is ok).
isoDates - is an ascending sorted list of ISO dates [times]
which may have duplicatestimeValue - an iso formatted date value
(with connector "T" or " " matching the isoDates)
public static int binaryFindFirstGE(java.lang.String[] isoDates,
java.lang.String timeValue)
If firstGE > lastLE, there are no matching elements (because the requested range is less than or greater than all the values, or between two adjacent values).
This throws RuntimeException if some years are negative (0000 is ok).
isoDates - is a sorted list of ISO dates [times]
which may have duplicatestimeValue - an iso formatted date value
(with connector "T" or " " matching the isoDates)
public static java.util.GregorianCalendar isoDateTimeAdd(java.lang.String isoDate,
int n,
int field)
throws java.lang.Exception
This correctly handles B.C. dates.
isoDate - an iso formatted date time string in UTC time zone.n - the number of 'units' to be addedfield - one of the Calendar or Calendar2 constants for a field
(e.g., Calendar2.YEAR).
java.lang.Exception - if trouble e.g., n is Integer.MAX_VALUEpublic static java.lang.String elapsedTimeString(double millis)
millis - may be negative
public static java.util.GregorianCalendar centerOfMonth(java.util.GregorianCalendar gc)
throws java.lang.Exception
gc -
java.lang.Exception - if trouble (e.g., gc is null)
public static java.util.GregorianCalendar clearSmallerFields(java.util.GregorianCalendar gc,
int field)
throws java.lang.Exception
gc - field - e.g., HOUR_OF_DAY
java.lang.Exception - if trouble (e.g., gc is null or field is not supported)
public static double backNDays(int nDays,
double max)
throws java.lang.Exception
nDays - max - seconds since epoch
java.lang.Exception
public static double[] getNEvenlySpaced(double start,
double stop,
int maxNValues)
start - epoch secondsstop - epoch secondsmaxNValues - maximum desired nValues
public static int nextNice(double d,
int[] nice)
d - a value e.g., 2.3 secondsnice - an ascending list. e.g., for seconds: 1,2,5,10,15,20,30,60
public static java.util.GregorianCalendar roundToIdealGC(double epochSeconds,
int idealN,
int idealUnits)
epochSeconds - idealN - e.g., 1 to 100idealUnits - an index of one of the IDEAL_UNITS
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||