Package com.api.jsonata4java.expressions
Class JS4JDate
java.lang.Object
java.util.Date
com.api.jsonata4java.expressions.JS4JDate
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Date>
Special object extends java.util.Date with special constructors
taking specific date formatted strings. The toString implementation
provides a formatted date suitable for sorting in the format
"yyyy/MM/ddTHH:mm:ss.SSS(Z)"
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFormat for parsing the create date string: 2004/08/04-07:23:15.987(-0400)static final StringFormat for parsing the create date string: 2004/08/04-07:23:15.987 which is assumed to be 0000 (Greenwich Mean Time).static final StringFormat for parsing the create date string: 2004/08/04-07:23:15 which is assumed to be 0000 (Greenwich Mean Time) with 0 milliseconds.static final StringFormat for parsing the create date string: 2004/08/04 07:23:15.987123 which is assumed to be 0000 (Greenwich Mean Time).static final StringFormat for parsing the create date string: Monday, 22 Sep 1959 08:12:34 which is assumed to be UTC (GMT)static final StringFormat for parsing the create date string: January 05 2018 00:44:45 which is assumed to be UTC (GMT)static final StringFormat for parsing the create date string: 2004/08/04-07:23 which is assumed to be 0000 (Greenwich Mean Time) with 0 seconds and milliseconds.static final StringFormat for parsing the create date string: 2004/08/04-07 which is assumed to be 0000 (Greenwich Mean Time) with 0 minutes, seconds and milliseconds.static final StringFormat for parsing the create date string: 2004/08/04 which is assumed to be 0000 (Greenwich Mean Time) at midnight.static final StringFormat for parsing the create date string: 2004/08/04-07:23:15(-0400) which is assumed to be -0400 (Eastern Daylight Time) with 0 milliseconds.static final StringFormat for parsing the create date string: 2004/08/04-07:23(-0400) which is assumed to be -0400 (Eastern Daylight Time) with 0 seconds and milliseconds.static final StringFormat for parsing the create date string: 2004/08/04-07(-0400) which is assumed to be -0400 (Eastern Daylight Time) with 0 minutes, seconds and milliseconds.static final StringFormat for parsing the create date string: 2004/08/04(-0400) which is assumed to be -0400 (Eastern Daylight Time) at midnight.static final StringFormat for parsing the create date string: 2004/08/04T07Z which is assumed to be 07:00:00.000 Zulu (UTC) Time.static final Stringstatic final JS4JDateAn undefined version of this object.static final longNumber of milliseconds past the 1/1/70 midnight epoch used to define an undefined datestatic final StringIntended to be equal to "1970-01-01 00:00:00.000001". -
Constructor Summary
ConstructorsConstructorDescriptionJS4JDate()Constructor forJS4JDate using the current date/time.JS4JDate(double dDate) Constructor initializing the time to the value supplied.JS4JDate(int iYear, int iMonth, int iDay, int iHours, int iMinutes, int iSeconds, int iMilliseconds, String strTimeZone) Create anJS4JDate object from the supplied date information.JS4JDate(long lDate) Constructor initializing the time to the value supplied.Create anJS4JDate object from the JS4JDate formatted date stringConstructor initializing the time to the date supplied. -
Method Summary
Modifier and TypeMethodDescriptionclone()intCompares this date with the supplied date and returns -1 if this date is less than the supplied date, 0 if equal, or 1 if greater than the supplied date.intstatic StringconvertDateTime(String strDateTime) Converts a String in xs:dateTime format toJS4JDate formatbooleanlongGet the day of this date for the specified timezone.static StringlongGet the hours of this date for the specified timezone.longgetMilliseconds(String strTimeZone) Get the milliseconds of this date for the specified timezone.longgetMinutes(String strTimeZone) Get the minutesr of this date for the specified timezone.longGet the month of this date for the specified timezone.longgetSeconds(String strTimeZone) Get the seconds of this date for the specified timezone.longGet the year of this date for the specified timezone.booleanTests for equality to the UNDEFINED_JS4JDate which is one second after the epoch date (midnight 1/1/1970 GMT).static booleanisUndefined(JS4JDate date) Tests for equality to the UNDEFINED_JS4JDate which is one millisecond after the epoch date (midnight 1/1/1970 GMT).static booleanisUndefined(Date date) Tests for equality to the UNDEFINED_JS4JDate which is one millisecond after the epoch date (midnight 1/1/1970 GMT).static DateGeneral purpose Date generator that parses multiple formats, supplying default values if they are unspecified.static StringmakeFormattedDate(Date date, String strFormat, String strTimeZone) Create a formatted string showing the date in the JS4JDate date format for 0000 (Greenwich Mean Time).static StringmakeFormattedLocalDate(Date date) Create a formatted string showing the local date in the JS4JDate date formatstatic longMAX_TIME()static JS4JDatestatic JS4JDatestatic StringparseTimeZoneFromListEntry(String strTimeZoneListEntry) Find the timezone string by parsing the timezone list entry formed by the getTimeZoneList routine.voidSet the day of this date to the specified day.voidSet the hours of this date to the specified hours.voidsetMilliseconds(int iMilliseconds, String strTimeZone) Set the milliseconds of this date to the specified seconds.voidsetMinutes(int iMinutes, String strTimeZone) Set the minutes of this date to the specified minutes.voidSet the month of this date to the specified month.voidsetSeconds(int iSeconds, String strTimeZone) Set the seconds of this date to the specified seconds.voidSet the year of this date to the specified year.toDate()toString()Return a String containing formatted date in the specified timezone.Return a String containing formatted date in the specified timezone.static JS4JDateundefinedForNull(JS4JDate date) Converts the inputJS4JDate to an undefinedJS4JDate if the inputJS4JDate is null.Methods inherited from class java.util.Date
after, before, from, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toInstant, toLocaleString, UTC
-
Field Details
-
CREATE_DATE_FORMAT
Format for parsing the create date string: 2004/08/04-07:23:15.987(-0400)- See Also:
-
CREATE_DATE_FORMAT_0
Format for parsing the create date string: 2004/08/04-07:23:15.987 which is assumed to be 0000 (Greenwich Mean Time).- See Also:
-
CREATE_DATE_FORMAT_1
Format for parsing the create date string: 2004/08/04-07:23:15 which is assumed to be 0000 (Greenwich Mean Time) with 0 milliseconds.- See Also:
-
CREATE_DATE_FORMAT_10
Format for parsing the create date string: 2004/08/04 07:23:15.987123 which is assumed to be 0000 (Greenwich Mean Time).- See Also:
-
CREATE_DATE_FORMAT_11
Format for parsing the create date string: Monday, 22 Sep 1959 08:12:34 which is assumed to be UTC (GMT)- See Also:
-
CREATE_DATE_FORMAT_12
Format for parsing the create date string: January 05 2018 00:44:45 which is assumed to be UTC (GMT)- See Also:
-
CREATE_DATE_FORMAT_2
Format for parsing the create date string: 2004/08/04-07:23 which is assumed to be 0000 (Greenwich Mean Time) with 0 seconds and milliseconds.- See Also:
-
CREATE_DATE_FORMAT_3
Format for parsing the create date string: 2004/08/04-07 which is assumed to be 0000 (Greenwich Mean Time) with 0 minutes, seconds and milliseconds.- See Also:
-
CREATE_DATE_FORMAT_4
Format for parsing the create date string: 2004/08/04 which is assumed to be 0000 (Greenwich Mean Time) at midnight.- See Also:
-
CREATE_DATE_FORMAT_5
Format for parsing the create date string: 2004/08/04-07:23:15(-0400) which is assumed to be -0400 (Eastern Daylight Time) with 0 milliseconds.- See Also:
-
CREATE_DATE_FORMAT_6
Format for parsing the create date string: 2004/08/04-07:23(-0400) which is assumed to be -0400 (Eastern Daylight Time) with 0 seconds and milliseconds.- See Also:
-
CREATE_DATE_FORMAT_7
Format for parsing the create date string: 2004/08/04-07(-0400) which is assumed to be -0400 (Eastern Daylight Time) with 0 minutes, seconds and milliseconds.- See Also:
-
CREATE_DATE_FORMAT_8
Format for parsing the create date string: 2004/08/04(-0400) which is assumed to be -0400 (Eastern Daylight Time) at midnight.- See Also:
-
CREATE_DATE_FORMAT_9
Format for parsing the create date string: 2004/08/04T07Z which is assumed to be 07:00:00.000 Zulu (UTC) Time.- See Also:
-
m_strClassName
-
UNDEFINED_JS4JDate_Milliseconds
public static final long UNDEFINED_JS4JDate_MillisecondsNumber of milliseconds past the 1/1/70 midnight epoch used to define an undefined date- See Also:
-
UNDEFINED_JS4JDate
An undefined version of this object. The undefined version is the epoch date + 1 created by newJS4JDate(1). -
UNDEFINED_JS4JDate_String
Intended to be equal to "1970-01-01 00:00:00.000001". That should be the result obtained from the calculation used here. In any case, that calculation should reflect the ways in which the elements involved are related. Note: This form of string for a timestamp can inserted via JDBC into a DB2 field of type Timestamp, but it requires a value that extends to six decimal places for seconds. Values shorter than that may be padded, but that may lead to warnings, if not errors, when loading data (and may complicate other things, as well).
-
-
Constructor Details
-
JS4JDate
public JS4JDate()Constructor forJS4JDate using the current date/time. -
JS4JDate
Constructor initializing the time to the date supplied.- Parameters:
date- the date for thisJS4JDate.
-
JS4JDate
public JS4JDate(double dDate) Constructor initializing the time to the value supplied.- Parameters:
dDate- the number of milliseconds since the epoch (midnight, 1/1/70 0000).
-
JS4JDate
public JS4JDate(int iYear, int iMonth, int iDay, int iHours, int iMinutes, int iSeconds, int iMilliseconds, String strTimeZone) throws Exception Create anJS4JDate object from the supplied date information.- Parameters:
iYear- 2, 3 or 4 digit year. If less than 4 digits, 2000 is added to the supplied value.iMonth- number of the month where 1=January, 12=December.iDay- number of the day of the month where the first day is 1.iHours- hours within the day from 0 through 23.iMinutes- minutes within the hour from 0 through 59.iSeconds- seconds within the minute from 0 through 59.iMilliseconds- milliseconds within the second from 0 through 999.strTimeZone- the timezone (e.g., "+0000" is Greenwich Mean Time, "-0400" is Eastern Daylight Time). If no timezone is supplied then "+0000" is used as a default.- Throws:
Exception- if the values for Day is invalid for the Month, or if an invalid Timezone is supplied (Exception), or if one of the values is not within their allowed range (ExceptionInvalidParam).
-
JS4JDate
public JS4JDate(long lDate) Constructor initializing the time to the value supplied.- Parameters:
lDate- the number of milliseconds since the epoch (midnight, 1/1/70 0000).
-
JS4JDate
Create anJS4JDate object from the JS4JDate formatted date string
-
-
Method Details
-
convertDateTime
Converts a String in xs:dateTime format toJS4JDate format- Parameters:
strDateTime- String in xs:dateTime format- Returns:
- String inJS4JDate format
- See Also:
-
getHexTime
- Returns:
- a String of hexadecimal characters representing the current time in milliseconds. This can be used as a name for temporary assets.
-
isUndefined
Tests for equality to the UNDEFINED_JS4JDate which is one millisecond after the epoch date (midnight 1/1/1970 GMT). This is used to identify and/or initialize anJS4JDate value that has yet to receive a valid value. Typically used for comparisons to glean if the value has been set properly.- Parameters:
date- the date to be tested to see if it is undefined- Returns:
- whether (true) or not (false) the supplied date is undefined
(meaning it is null or its
Date.getTime()returns a value of 1L - See Also:
-
isUndefined
Tests for equality to the UNDEFINED_JS4JDate which is one millisecond after the epoch date (midnight 1/1/1970 GMT). This is used to identify and/or initialize anJS4JDate value that has yet to receive a valid value. Typically used for comparisons to glean if the value has been set properly.- Parameters:
date- the date to be tested to see if it is undefined- Returns:
- whether (true) or not (false) the supplied date is undefined
(meaning it is null or its
Date.getTime()returns a value of 1L - See Also:
-
makeDate
General purpose Date generator that parses multiple formats, supplying default values if they are unspecified. -
makeFormattedDate
Create a formatted string showing the date in the JS4JDate date format for 0000 (Greenwich Mean Time).- Parameters:
date- the date to be transformed into the string.strFormat- the date format to be returned. If the format is ill defined, the standard JS4JDate Date format is used (CREATE_DATE_FORMAT).strTimeZone- the format of the timezone using +/-hhmm- Returns:
- a formatted string showing the local date in the JS4JDate date format
- See Also:
-
makeFormattedLocalDate
Create a formatted string showing the local date in the JS4JDate date format- Parameters:
date- the date to be transformed into the string.- Returns:
- a formatted string showing the local date in the JS4JDate date format
- See Also:
-
MAX_TIME
public static long MAX_TIME() -
MAX_VALUE
- Returns:
- the largest date that matches the JS4JDate Date Format for any timezone. The value is the date "9999/12/30-23:59:59.999(+0000)" -- the extra day allows for any timezone to be added and still have a 4 digit year.
-
MIN_VALUE
- Returns:
- the earliest date that matches the JS4JDate Date Format for any timezone. The value is the date of the epoch "1970/01/01-00:00:00.000(+0000)"
-
parseTimeZoneFromListEntry
Find the timezone string by parsing the timezone list entry formed by the getTimeZoneList routine.- Parameters:
strTimeZoneListEntry- the timezone list entry from the getTimeZoneList method comprising the timezone offset from GMT followed by a space and then the TimeZone ID. For example, "+0100 Europe/Paris" or "-0500 EST" or "+0000 GMT" would return "+0100", "-0500", or "+0000" respectively.- Returns:
- the timezone in the form +/-hhmm (e.g., +0000 is GMT, -0500 is Eastern Standard Time, +0100 is Europe/Paris. If the passed timezone list entry is null, empty, or does not comply with the expected format, the GMT timezone "+0000" is returned.
-
undefinedForNull
Converts the inputJS4JDate to an undefinedJS4JDate if the inputJS4JDate is null.- Parameters:
date- JS4JDate to be tested against null and converted.- Returns:
- An undefinedJS4JDate if the inputJS4JDate was null, otherwise, the inputJS4JDate is echoed back.
-
clone
-
compareTo
Compares this date with the supplied date and returns -1 if this date is less than the supplied date, 0 if equal, or 1 if greater than the supplied date.- Parameters:
date- the date to compare against this date- Returns:
- -1 if this date is less than the supplied date, 0 if equal, or 1 if greater than the supplied date.
-
compareTo
- Specified by:
compareToin interfaceComparable<Date>- Overrides:
compareToin classDate
-
equals
-
getDay
Get the day of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the day applies. If this value is null or empty, "+0000" is used.- Returns:
- the day of this date for the specified timezone.
-
getHours
Get the hours of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the hours apply. If this value is null or empty, "+0000" is used.- Returns:
- the hours of this date for the specified timezone.
-
getMilliseconds
Get the milliseconds of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the milliseconds apply. If this value is null or empty, "+0000" is used.- Returns:
- the milliseconds of this date for the specified timezone.
-
getMinutes
Get the minutesr of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the minutes apply. If this value is null or empty, "+0000" is used.- Returns:
- the month of this date for the specified timezone.
-
getMonth
Get the month of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the month applies. If this value is null or empty, "+0000" is used.- Returns:
- the month of this date for the specified timezone.
-
getSeconds
Get the seconds of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the seconds apply. If this value is null or empty, "+0000" is used.- Returns:
- the seconds of this date for the specified timezone.
-
getYear
Get the year of this date for the specified timezone.- Parameters:
strTimeZone- the timezone for which the year applies. If this value is null or empty, "+0000" is used.- Returns:
- the year of this date for the specified timezone.
-
isUndefined
public boolean isUndefined()Tests for equality to the UNDEFINED_JS4JDate which is one second after the epoch date (midnight 1/1/1970 GMT). This is used to identify and/or initialize anJS4JDate value that has yet to receive a valid value. Typically used for comparisons to glean if the value has been set properly.- Returns:
- whether (true) or not (false) this object is undefined
- See Also:
-
setDay
Set the day of this date to the specified day.- Parameters:
iDay- the day of the month (first day is 1).strTimeZone- the timezone for which the day applies. If this value is null or empty, "+0000" is used.
-
setHours
Set the hours of this date to the specified hours.- Parameters:
iHours- the hours within the day (0=midnight).strTimeZone- the timezone for which the hours apply. If this value is null or empty, "+0000" is used.
-
setMilliseconds
Set the milliseconds of this date to the specified seconds.- Parameters:
iMilliseconds- the milliseconds within the second [0..999].strTimeZone- the timezone for which the milliseconds apply. If this value is null or empty, "+0000" is used.
-
setMinutes
Set the minutes of this date to the specified minutes.- Parameters:
iMinutes- the minutes within the hour [0..59].strTimeZone- the timezone for which the minutes apply. If this value is null or empty, "+0000" is used.
-
setMonth
Set the month of this date to the specified month.- Parameters:
iMonth- the one-based counting month number (e.g., 1=January).strTimeZone- the timezone for which the month applies. If this value is null or empty, "+0000" is used.
-
setSeconds
Set the seconds of this date to the specified seconds.- Parameters:
iSeconds- the seconds within the minute [0..59].strTimeZone- the timezone for which the seconds apply. If this value is null or empty, "+0000" is used.
-
setYear
Set the year of this date to the specified year.- Parameters:
iYear- the complete, 4 digit year (yeah, Y10K bug... ;^)strTimeZone- the timezone for which the year applies. If this value is null or empty, "+0000" is used.
-
toDate
-
toString
- Overrides:
toStringin classDate- Returns:
- the formatted date using "yyyy-MM-ddTHH:mm:ss.SSS(Z)" where yyyy is the 4 digit year, MM is the 2 digit month, dd is the 2 digit day, HH is the 2 digit hours, mm is the 2 digit minutes, ss is the 2 digit seconds, SSS is the 3 digit milliseconds, and Z is GMT (e.g., +0000). For example, August 4th, 2004 at 7:15:35.456 AM Greenwich Mean Time is "2004-08-04T07:15:35.456Z"
- See Also:
-
toString
Return a String containing formatted date in the specified timezone.- Parameters:
strTimeZone- the ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "0000-8:00". Note that the support of abbreviations is for JDK 1.1.x compatibility only and full names should be used.- Returns:
- the formatted date using "yyyy/MM/dd-HH:mm:ss.SSS(Z)" where yyyy is the 4 digit year, MM is the 2 digit month, dd is the 2 digit day, HH is the 2 digit hours, mm is the 2 digit minutes, ss is the 2 digit seconds, SSS is the 3 digit milliseconds, and z is the 3 character timezone. For example, August 4th, 2004 at 7:15:35.456 AM Greenwich Mean Time is "2004/08/04-07:15:35.456(+0000)"
- See Also:
-
toString
Return a String containing formatted date in the specified timezone.- Parameters:
strFormat- the desired date format to be returned. If the format is invalid, the standard JS4JDate Date format is used (CREATE_DATE_FORMAT).strTimeZone- the ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "0000-8:00". Note that the support of abbreviations is for JDK 1.1.x compatibility only and full names should be used.- Returns:
- the formatted date using "yyyy/MM/dd-HH:mm:ss.SSS(Z)" where yyyy is the 4 digit year, MM is the 2 digit month, dd is the 2 digit day, HH is the 2 digit hours, mm is the 2 digit minutes, ss is the 2 digit seconds, SSS is the 3 digit milliseconds, and z is the 3 character timezone. For example, August 4th, 2004 at 7:15:35.456 AM Greenwich Mean Time is "2004/08/04-07:15:35.456(0000)"
- See Also:
-
toStringCookie
- Returns:
- the formatted date using "yyyy-MM-dd HH:mm:ss.SSS" where yyyy is the 4 digit year, MM is the 2 digit month, dd is the 2 digit day, HH is the 2 digit hours, mm is the 2 digit minutes, ss is the 2 digit seconds, SSS is the 3 digit milliseconds in GMT timezone (e.g., +0000). For example, August 4th, 2004 at 7:15:35.456 AM Greenwich Mean Time is "2004-08-04 07:15:35.456"
- See Also:
-
toStringDateTime
- Returns:
- the formatted date using "yyyy-MM-ddTHH:mm:ss.SSSZ" where yyyy is the 4 digit year, MM is the 2 digit month, dd is the 2 digit day, HH is the 2 digit hours, mm is the 2 digit minutes, ss is the 2 digit seconds, SSS is the 3 digit milliseconds, and , and Z is GMT (e.g., +0000). For example, August 4th, 2004 at 7:15:35.456 AM Greenwich Mean Time is "2004/08/04T07:15:35.456(0000)"
- See Also:
-
toStringDBTimestamp
- Returns:
- the formatted date using "yyyy-MM-dd HH:mm:ss.SSS" where yyyy is the 4 digit year, MM is the 2 digit month, dd is the 2 digit day, HH is the 2 digit hours, mm is the 2 digit minutes, ss is the 2 digit seconds, SSS is the 3 digit milliseconds in GMT timezone (e.g., +0000). For example, August 4th, 2004 at 7:15:35.456 AM Greenwich Mean Time is "2004-08-04 07:15:35.456"
- See Also:
-