public class datetimetz extends datetime
This class extends the datetime
class so all methods should work
directly. If they don't they will be overridden. Also should the following
static implementations:
now function (as initializer for datetime-tz)now()
datetime-tz function (date, integer)datetimetz(date, NumberType)
datetime-tz function (datetime, integer)datetimetz(date, NumberType)
datetime-tz function (datetime-tz, integer)datetimetz(date, NumberType)
datetime-tz function (date, integer, integer)datetimetz(date, NumberType, NumberType)
datetime-tz function (integer m, d, y, h, mm, s, ms, tz)datetimetz(NumberType, NumberType, NumberType, NumberType, NumberType, NumberType, NumberType, NumberType)
datetime-tz function (string parameter)datetimetz(String)
timezone function (datetime-tz parameter)getTimeZoneOffset()
[literal]fromLiteral(String)
Default data type display format: 99/99/9999 HH:MM:SS.SSS+HH:MM
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
defaultFormat
The default format string.
|
private int |
offset
Time zone offset in minutes from Coordinated Universal Time (UTC).
|
AMPM, HOURS, MILLIS, MINUTES, SECONDS, TZ_HOURS, TZ_MINS
DAY, INVALID_DATE, INVALID_TZ, JULIAN_EPOCH_OFFSET, MAX_VALID_TZ, MILLIS_PER_DAY, MIN_VALID_TZ, MONTH, ORDER_MDY, ORDER_YMD, YEAR
Constructor and Description |
---|
datetimetz()
Default constructor builds an unknown object.
|
datetimetz(BaseDataType value)
This is a special c'tor which should be used only when converting the
value returned by a function or method with polymorphic return type into the
expected type (i.e.
|
datetimetz(java.util.Calendar calendar)
Creates a new instance from the given calendar value.
|
datetimetz(character spec)
Creates a new instance from the given date and time specification.
|
datetimetz(date d)
Constructs an instance with the exact same state as the passed
instance.
|
datetimetz(date d,
double timeOrOffset)
Constructs an instance using the inputs, with varying behavior depending
on the type of the first parameter.
|
datetimetz(date d,
double time,
double offset)
Constructs an instance using the inputs.
|
datetimetz(date d,
double time,
NumberType offset)
Constructs an instance using the inputs.
|
datetimetz(date d,
NumberType timeOrOffset)
Constructs an instance using the inputs, with varying behavior depending
on the type of the first parameter.
|
datetimetz(date d,
NumberType time,
double offset)
Constructs an instance using the inputs.
|
datetimetz(date d,
NumberType time,
NumberType offset)
Constructs an instance using the inputs.
|
datetimetz(double month,
double day,
double year,
double hours,
double minutes)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(double month,
double day,
double year,
double hours,
double minutes,
double seconds)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(double month,
double day,
double year,
double hours,
double minutes,
double seconds,
double millis)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(double month,
double day,
double year,
double hours,
double minutes,
double seconds,
double millis,
double offset)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(NumberType month,
NumberType day,
NumberType year,
NumberType hours,
NumberType minutes)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(NumberType month,
NumberType day,
NumberType year,
NumberType hours,
NumberType minutes,
NumberType seconds)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(NumberType month,
NumberType day,
NumberType year,
NumberType hours,
NumberType minutes,
NumberType seconds,
NumberType millis)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(NumberType month,
NumberType day,
NumberType year,
NumberType hours,
NumberType minutes,
NumberType seconds,
NumberType millis,
NumberType offset)
Construct a datetime instance using explicit values for each discrete
component.
|
datetimetz(java.lang.String spec)
Creates a new instance from the given date and time specification.
|
datetimetz(java.lang.String spec,
java.lang.String format,
int windowingYear)
Converts a string to a datetime-tz using a specified format and an optional windowing year
for date part.
|
Modifier and Type | Method and Description |
---|---|
void |
assign(BaseDataType value,
boolean force)
Sets the state (data and unknown value) of this instance based on the
state of the passed instance.
|
void |
assign(date value,
boolean force)
Sets the state of this instance based on the state of the passed instance.
|
java.util.Calendar |
calendarValue()
Converts this object to a Calendar value to be used by Hibernate persistence.
|
int |
compareTo(java.lang.Object obj)
Compares this instance with the specified instance and returns a -1 if this instance is
less than the specified, 0 if the two instances are equal and 1 if this instance is greater
than the specified instance.
|
void |
deepAssign(datetimetz value)
Sets the state (data and unknown value) and configuration (time-zone)
of this instance based on the state of the passed instance.
|
java.lang.String |
defaultFormatString()
Return the default display format string for this type.
|
BaseDataType |
duplicate()
Does the same as standard
clone() method but returns an instance of
BaseDataType and doesn't throw the CloneNotSupportedException . |
boolean |
equals(java.lang.Object o)
An equality test which handles the most common cases with the least amount of overhead.
|
static datetimetz |
fromLiteral(java.lang.String str)
Check if the
str is a Progress datetime-tz literal (in ISO8601 format string
representation), parse it and return the datetimetz object. |
static int |
getDefaultTimezoneOffset(date d)
Computes the local offset (raw + DST) from UTC at a specified date.
|
protected java.lang.String |
getIsoDate()
Obtains the text form of this date instance in ISO 8601 standard format.
|
int |
getOffset()
Get the offset in minutes from UTC for this instance.
|
int64 |
getTimeZoneOffset()
Obtains the timezone offset in minutes from UTC for this instance.
|
java.lang.String |
getTypeName()
Returns the legacy type name of the this class.
|
int |
getTzHours()
Obtains the hours of timezone offset.
|
int |
getTzMinutes()
Obtains the minutes of timezone offset.
|
int |
hashCode()
Hash code implementation which is consistent with
BaseDataType.equals(java.lang.Object) . |
BaseDataType |
instantiateDefault()
Creates a new instance of the same type that represents the default initialized value.
|
BaseDataType |
instantiateUnknown()
Creates a new instance of the same type that represents the
unknown value . |
static datetimetz |
instantiateUnknownDatetimeTz()
Deprecated.
|
private static java.lang.String |
isoFormat(int y,
int M,
int d,
int h,
int m,
int s,
int t,
int z)
Private utility method that returns a date (by components) as string in ISO format
(yyyy-MM-dd hh:mm:ss.ttt).
|
static void |
main(java.lang.String[] args)
Sample testing.
|
static datetimetz |
now()
Creates an instance that represents current date and time using the default timezone.
|
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
void |
setTime(long hours,
long mins,
long secs,
long millis,
long offset)
Sets the internal time and offset.
|
void |
setTime(NumberType hours,
NumberType mins,
NumberType secs,
NumberType millis,
NumberType offset)
Sets the internal time and offset.
|
void |
setTimestamp(java.util.Date date)
Reinitialize date and time components of this object from the date parameter.
|
void |
setTimeZoneOffset(long offset)
Set the offset in minutes from UTC for this instance.
|
datetime |
toLocalDatetime()
Return an object equal to this expressed in local time (current timezone offset).
|
datetimetz |
toOffset(int offsetInMinutes)
Moves the current datetime-tz to another timezone offset.
|
private static java.lang.String |
toString(java.util.Calendar c)
Private utility method that returns a Calendar value as string in ISO format
(yyyy-MM-dd hh:mm:ss.ttt).
|
java.lang.String |
toStringExport()
Creates a string representation of the instance data using the Progress 4GL 'export' format.
|
java.lang.String |
toStringSQL()
Creates a SQL compatible string representation of the instance data
(the format is "YYYY-MM-DD HH:MM:SS.zzz+HH:MM").
|
static ErrorManager.ErrorEntry |
validate(int month,
int day,
int year,
boolean forceFourDigits,
int hours,
int minutes,
int seconds,
int millis,
java.lang.String ampm,
int tz_hours,
int tz_minutes)
Validate specified values and return error information if they don't consist of correct
datetime components.
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
dateValue, dateValue, deepAssign, differenceNum, generateParsingError, getAbsoluteTimeOffset, getHours, getHoursNum, getMilliseconds, getMillisecondsNum, getMinutes, getMinutesNum, getSeconds, getSecondsNum, getTime, getTimeNum, getTzHoursNum, getTzMinutesNum, instantiateFromDateTime, instantiateFromStringWorker, instantiateUnknownDatetime, millisecondsSinceMidnight, millisecondsSinceMidnight, minusMillis, minusMillis, plusMillis, plusMillis, setTime, setTime, setTime, setTime, toString
assign, assign, calendarToLocalMillis, cleanFormattedDate, dateToLocalMillis, day, decimalValue, decrement, deepAssign, difference, differenceNum, doubleValue, elapsed, elapsed, elapsed, genBadCharInFormatError, getDateComponentOrder, getDateOrder, getDay, getDayNum, getDefaultOffset, getDefaultTimeZone, getDefaultTimeZoneOffset, getDisplayTimeZone, getMonth, getMonthNum, getOffsetForSpec, getOffsetForSpec, getSessionTimeZone, getTimeSource, getWeekday, getWeekdayNum, getWindowingYear, getYear, getYearNum, getYearOffset, getZoneCalendar, getZoneFromOffset, increment, initFormat, instantiateDate, instantiateUnknownDate, integerValue, intValue, inY2KWindow, isoDate, isUnknown, julianDayToMillis, longValue, maximum, maximum, millisToJulianDay, minimum, minimum, minusDays, minusDays, minusDays, month, neutralMillisToCalendar, neutralMillisToDate, plusDays, plusDays, plusDays, secondsSinceMidnight, secondsSinceMidnight, setDateComponentOrder, setDateOrder, setDateOrder, setDayNumber, setDayNumber, setDayNumber, setDisplayTimeZone, setDisplayTimeZone, setSessionTimeZone, setSessionTimeZone, setTimeSource, setTimeSource, setUnknown, setWindowingYear, setYearOffset, specToOffset, today, toString, toStringMessage, toYearString, validate, weekday, windowingImpl, year
assign, calcFormatLength, deepCopy, elementsOfType, formatLength, generateDefault, generateUnknown, incompatibleTypesOnConversion, initializeDefaultExtent, instantiateDefaultExtent, isUnknownValue, maximum, minimum, notUnknownValue, sameType
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobal
private static final java.lang.String defaultFormat
private int offset
public datetimetz()
public datetimetz(BaseDataType value)
assign(BaseDataType, boolean)
).value
- The value to be used for this instance.public datetimetz(date d)
date
subclass.d
- The instance from which to copy state.public datetimetz(date d, NumberType timeOrOffset)
If the first parameter is a date
instance, then the date is
copied from that instance and the second parameter is treated as the
time value (number of milliseconds since midnight).
If the first parameter is a datetime
or
datetimetz
instance, then the date and time is copied from
the instance and the second parameter is treated as a positive or
negative timezone offset for the new instance.
This is an implementation of 3 forms of the DATETIME-TZ() built-in function.
The time value (positive or negative) is added to the date and the resulting value will be used to determine the date and time based on the default timezone. In other words, the date value can change in either direction by an arbitrary magnitude. This is how it is done in the 4GL.
Any input that is unknown
will cause this instance to be
unknown
.
d
- The date (or date subclass) from which to copy.timeOrOffset
- The milliseconds since midnight if the first parameter is a
date
or a timezone offset from UTC in minutes
if the first parameter is a datetime
. As an
offset, the value must be between -840 and 840.public datetimetz(date d, double timeOrOffset)
If the first parameter is a date
instance, then the date is
copied from that instance and the second parameter is treated as the
time value (number of milliseconds since midnight).
If the first parameter is a datetime
or
datetimetz
instance, then the date and time is copied from
the instance and the second parameter is treated as a positive or
negative timezone offset for the new instance.
This is an implementation of 3 forms of the DATETIME-TZ() built-in function.
The time value (positive or negative) is added to the date and the resulting value will be used to determine the date and time based on the default timezone. In other words, the date value can change in either direction by an arbitrary magnitude. This is how it is done in the 4GL.
Any input that is unknown
will cause this instance to be
unknown
.
d
- The date (or date subclass) from which to copy.timeOrOffset
- The milliseconds since midnight if the first parameter is a
date
or a timezone offset from UTC in minutes
if the first parameter is a datetime
. As an
offset, the value must be between -840 and 840.public datetimetz(date d, NumberType time, NumberType offset)
This is an implementation of 1 form of the DATETIME-TZ() built-in function.
The time value (positive or negative) is added to the date and the resulting value will be used to determine the date and time based on the given timezone. In other words, the date value can change in either direction by an arbitrary magnitude. This is how it is done in the 4GL.
Any input that is unknown
will cause this instance to be
unknown
.
d
- The date from which to copy. This must be an instance of the
date
superclass and may NOT be an instance of the
datetime
or datetimetz
since that is
a 4GL error.time
- The milliseconds since midnight.offset
- The timezone offset from UTC in minutes. Must be between -840 and 840 inclusive.public datetimetz(date d, NumberType time, double offset)
This is an implementation of 1 form of the DATETIME-TZ() built-in function.
The time value (positive or negative) is added to the date and the resulting value will be used to determine the date and time based on the given timezone. In other words, the date value can change in either direction by an arbitrary magnitude. This is how it is done in the 4GL.
Any input that is unknown
will cause this instance to be
unknown
.
d
- The date from which to copy. This must be an instance of the
date
superclass and may NOT be an instance of the
datetime
or datetimetz
since that is
a 4GL error.time
- The milliseconds since midnight.offset
- The timezone offset from UTC in minutes. Must be between -840 and 840 inclusive.public datetimetz(date d, double time, NumberType offset)
This is an implementation of 1 form of the DATETIME-TZ() built-in function.
The time value (positive or negative) is added to the date and the resulting value will be used to determine the date and time based on the given timezone. In other words, the date value can change in either direction by an arbitrary magnitude. This is how it is done in the 4GL.
Any input that is unknown
will cause this instance to be
unknown
.
d
- The date from which to copy. This must be an instance of the
date
superclass and may NOT be an instance of the
datetime
or datetimetz
since that is a 4GL error.time
- The milliseconds since midnight.offset
- The timezone offset from UTC in minutes. Must be between -840 and 840 inclusive.public datetimetz(date d, double time, double offset)
This is an implementation of 1 form of the DATETIME-TZ() built-in function.
The time value (positive or negative) is added to the date and the resulting value will be used to determine the date and time based on the given timezone. In other words, the date value can change in either direction by an arbitrary magnitude. This is how it is done in the 4GL.
Any input that is unknown
will cause this instance to be
unknown
.
d
- The date from which to copy. This must be an instance of the
date
superclass and may NOT be an instance of the
datetime
or datetimetz
since that is a 4GL error.time
- The milliseconds since midnight.offset
- The timezone offset from UTC in minutes. Must be between -840 and 840 inclusive.public datetimetz(double month, double day, double year, double hours, double minutes, double seconds, double millis)
month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.seconds
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.millis
- The milliseconds of the second from 0 to 999 inclusive.public datetimetz(double month, double day, double year, double hours, double minutes, double seconds, double millis, double offset)
month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.seconds
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.millis
- The milliseconds of the second from 0 to 999 inclusive.
The offset in minutes from UTC. Must be between -840 and 840
inclusive.public datetimetz(double month, double day, double year, double hours, double minutes, double seconds)
month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.seconds
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.public datetimetz(double month, double day, double year, double hours, double minutes)
month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.public datetimetz(NumberType month, NumberType day, NumberType year, NumberType hours, NumberType minutes, NumberType seconds, NumberType millis)
unknown
will result in the instance being
unknown
.month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.seconds
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.millis
- The milliseconds of the second from 0 to 999 inclusive.public datetimetz(NumberType month, NumberType day, NumberType year, NumberType hours, NumberType minutes, NumberType seconds, NumberType millis, NumberType offset)
unknown
will result in the instance being
unknown
.month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.seconds
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.millis
- The milliseconds of the second from 0 to 999 inclusive.offset
- The offset in minutes from UTC. Must be between -840 and 840
inclusive.public datetimetz(NumberType month, NumberType day, NumberType year, NumberType hours, NumberType minutes, NumberType seconds)
unknown
will result in the instance being
unknown
.month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.seconds
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.public datetimetz(NumberType month, NumberType day, NumberType year, NumberType hours, NumberType minutes)
unknown
will result in the instance being
unknown
.month
- The month number from 1 to 12 inclusive.day
- The day of the month from 1 to the maximum days in that month,
inclusiveyear
- The Progress 4GL year which may be a negative number which
represents the BC era or a positive AD era year. The value must
be between -32768 and 32767 and it cannot be 0 since the year
0 is invalid in Progress. The value will be windowed into the
right century if it is 2 digits. It will be used unchanged if
it is 3 or more digits.hours
- The hour of the day from 0 to 23 inclusive.minutes
- The minute of the hour from 0 to 59 inclusive.public datetimetz(java.lang.String spec) throws ErrorConditionException
The specification must match the following format rules:
spec
- The date and time specification.ErrorConditionException
public datetimetz(java.lang.String spec, java.lang.String format, int windowingYear) throws ErrorConditionException
spec
- The date and time specification.format
- The format string used for date conversion.windowingYear
- The start of the 100 year window used for conversion when year is in 2-digits.ErrorConditionException
datetimetz(String)
public datetimetz(character spec) throws ErrorConditionException
unknown
the instance will be unknown
.
The specification must match the following format rules:
spec
- The date and time specification.ErrorConditionException
public datetimetz(java.util.Calendar calendar)
calendar
- The Calendar to be used for creating new instance.public static datetimetz now()
public datetimetz toOffset(int offsetInMinutes)
offsetInMinutes
- The new timezone offset to move this object.public static datetimetz fromLiteral(java.lang.String str)
str
is a Progress datetime-tz literal (in ISO8601 format string
representation), parse it and return the datetimetz
object.
The recognized formats are:
YYYY-MM-ddTHH:mm[:S[S].s[s[s[...]]]+H[[H]:M[M]]]where the date-separator can be either 't' or 'T' and timezone can be both positive '+' or negative '-'. The hours and minutes are mandatory in 2 digits and seconds, tz-hours and tz-minutes can be represented as 1 or 2 digits. The seconds parts can be tenths of seconds (one digit), hundredths (2 digits) and milliseconds (3 digits after '.'). If more digits appear after '.'they are ignored. Normally the timezone should be present, otherwise P2J parser wouldn't classified it as a datetime-tz literal.
str
- The text to be parsed.@Deprecated public static datetimetz instantiateUnknownDatetimeTz()
datetimetz
instance that represents the
unknown value
.
This method is deprecated. Use the default constructor instead.
unknown value
.public BaseDataType instantiateUnknown()
unknown value
.instantiateUnknown
in class datetime
unknown value
.public BaseDataType instantiateDefault()
instantiateDefault
in class datetime
public java.lang.String defaultFormatString()
defaultFormatString
in class datetime
public void assign(BaseDataType value, boolean force)
If the value is not of type datetimetz
, the following automatic type
conversion will occur:
This conversion is meant to handle the cases of built-in functions and methods in the 4GL which have polymorphic return types (e.g. DYNAMIC-FUNCTION()).
assign
in class datetime
value
- The instance from which to copy state.force
- Flag to indicate if a pending error should be ignored (see
ErrorManager.isPendingError()
and the assignment
forced regardless. Note that normal assignment silently
exits with no change if there is a pending error. If this
flag is true
, that check is bypassed and the
assignment will always be done.public void assign(date value, boolean force)
value
is a date
or
datetime
) time and timezome, 00:00 is assumed.assign
in class datetime
value
- The instance from which to copy state.force
- Flag to indicate if a pending error should be ignored (see
ErrorManager.isPendingError()
and the assignment forced regardless. Note
that normal assignment silently exits with no change if there is a pending error.
If this flag is true
, that check is bypassed and the assignment will
always be done.public void deepAssign(datetimetz value)
value
- The instance from which to copy state.public int compareTo(java.lang.Object obj)
Comparable
interface.
The algorithm will fail to give meaningful results in the case where one tries to sort against other objects that do not represent compatible values.
Before comparing, both datetime-tz values are translated to UTC. There are no unique objects: the following are equals: 2001-06-30T22:59:59.999+05:00 EQ 2001-06-30T23:59:59.999+06:00 and 2001-06-30T23:59:59.999+05:00 GT 2001-06-30T23:59:59.999+06:00 is positive.
public boolean equals(java.lang.Object o)
This implementation is consistent with hashCode()
.
equals
in class datetime
o
- The instance to compare against.true
if the objects compare equivalently; false
if they do not,
or if the parameter is not a BaseDataType
instance.BaseDataType.equals(java.lang.Object)
public int hashCode()
BaseDataType.equals(java.lang.Object)
.public BaseDataType duplicate()
clone()
method but returns an instance of
BaseDataType
and doesn't throw the CloneNotSupportedException
.public int64 getTimeZoneOffset()
public java.lang.String getTypeName()
getTypeName
in class BaseDataType
public int getOffset()
public void setTimeZoneOffset(long offset)
setTimeZoneOffset
in class datetime
offset
- The offset, must be between -840 and 840 inclusive.public void setTime(NumberType hours, NumberType mins, NumberType secs, NumberType millis, NumberType offset)
unknown
will cause this instance to be unknown
.hours
- The hour of the day from 0 to 23 inclusive.mins
- The minute of the hour from 0 to 59 inclusive.secs
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.millis
- The milliseconds of the second from 0 to 999 inclusive.offset
- The timezone offset in minutes from UTC. Must be between
-840 and 840 inclusive.public void setTime(long hours, long mins, long secs, long millis, long offset)
hours
- The hour of the day from 0 to 23 inclusive.mins
- The minute of the hour from 0 to 59 inclusive.secs
- The seconds of the minute from 0 to 62 inclusive. This accounts
for leap seconds. Please note that Progress documents 61 as
the limit. It turns out that 62 is the real limit.millis
- The milliseconds of the second from 0 to 999 inclusive.offset
- The timezone offset in minutes from UTC. Must be between
-840 and 840 inclusive.public java.lang.String toStringSQL()
The year component is treated differently since it can have a sign (negative indicates BC era) and if the date is within the Y2K window it is truncated to fit.
toStringSQL
in class datetime
public java.lang.String toStringExport()
This implementation creates the given string based on the order of date components (e.g. MDY, YMD...) defined for this context.
toStringExport
in class datetime
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class datetime
in
- The input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class datetime
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public final datetime toLocalDatetime()
toLocalDatetime
in class datetime
protected java.lang.String getIsoDate()
getIsoDate
in class datetime
unknown
.public static int getDefaultTimezoneOffset(date d)
d
- The date for which the offset is computed. If null, the current JVM date is used.public int getTzMinutes()
getTzMinutes
in class datetime
public int getTzHours()
getTzHours
in class datetime
public static ErrorManager.ErrorEntry validate(int month, int day, int year, boolean forceFourDigits, int hours, int minutes, int seconds, int millis, java.lang.String ampm, int tz_hours, int tz_minutes)
month
- The month.day
- The day.year
- The year.forceFourDigits
- Flags that the year should be in 4 digits format.hours
- The hours.minutes
- The minutes.seconds
- The seconds.millis
- The milliseconds.ampm
- AM/PM indicator, or null/empty for 24H representationtz_hours
- Timezone hours (can be negative).tz_minutes
- Timezone minutes.null
if components are valid and error information otherwise.public void setTimestamp(java.util.Date date)
This method is only used from DatetimeTzUserType
when restoring an object form
database. As it is stored as a compound type, the initialization happens in two atomic
steps.
date
- The date to be used for restoring date and time subcomponents.public java.util.Calendar calendarValue()
private static java.lang.String toString(java.util.Calendar c)
c
- The calendar.private static java.lang.String isoFormat(int y, int M, int d, int h, int m, int s, int t, int z)
y
- the year (4 digits)M
- the month (1-12)d
- the day (1-31)h
- the hour of the day (0-23)m
- the minute of the hour (0-59)s
- the second (0-59)t
- the milliseconds (0-999)z
- the time offset from UTC (in minutes, -840 - 840)public static void main(java.lang.String[] args)
Displays the current date/time from various sources (date OS command, java
Date
, java GregorianCalendar
,
P2J date.today()
,
P2J datetime.now()
,
P2J now()
that must be compared by hand.
Builds a lots of datetime-tz
instances (built with fromLiteral(String)
)
from a small database of sensible data instances and compare the string representation of
different outputs:
toStringExport()
- MESSAGE P4GL output
getIsoDate()
- output of ISO-DATE P4GL function
calendarValue()
- Calendar export of internal value of P2J datatype to Java
args
- ignored.