public class datetime extends date
This class extends the date
class so all methods should work
directly. If they don't they will be overridden. Also should the following
static implementations:
+ operator (datetime, integer)plusMillis(datetime, NumberType)
- operator (datetime, integer)minusMillis(datetime, NumberType)
- operator (datetime, datetime)differenceNum(datetime, datetime)
string function (default format)date.toString()
(user-defined format)toString(String)
(export format)toStringExport()
now functionnow()
datetime function (date)datetime(date)
datetime function (date, integer)datetime(date, NumberType)
datetime function (integer m, d, y, h, mm, s, ms)datetime(NumberType, NumberType, NumberType, NumberType, NumberType, NumberType, NumberType)
datetime function (string parameter)datetime(String)
[literal]fromLiteral(String)
Default data type display formats: DATETIME 99/99/9999 HH:MM:SS.SSS
Modifier and Type | Field and Description |
---|---|
static byte |
AMPM
Represents the AM/PM string component of
|
private static java.lang.String |
defaultFormat
The default format string.
|
static byte |
HOURS
Represents the hours component of the string formatted datetime(-tz).
|
static byte |
MILLIS
Represents the milliseconds component of the string formatted datetime(-tz).
|
static byte |
MINUTES
Represents the minutes component of the string formatted datetime(-tz).
|
static byte |
SECONDS
Represents the seconds component of the string formatted datetime(-tz).
|
private int |
time
The milliseconds since midnight.
|
static byte |
TZ_HOURS
Represents the hours time zone component of the string formatted datetime(-tz).
|
static byte |
TZ_MINS
Represents the minutes time zone component of the string formatted datetime(-tz).
|
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 |
---|
datetime()
Default constructor which creates an unknown instance.
|
datetime(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.
|
datetime(character spec)
Creates a new instance from the given date and time specification.
|
datetime(date d)
Constructs an instance with the exact same state as the passed
instance.
|
datetime(java.util.Date d)
Creates an instance from a
java.util.Date instance. |
datetime(date d,
double time)
Constructs an instance with the exact same state as the passed
instance and having the specified time.
|
datetime(date d,
NumberType time)
Constructs an instance with the exact same state as the passed
instance and having the specified time.
|
datetime(java.util.Date d,
java.util.TimeZone zone)
Creates an instance from a
java.util.Date instance. |
datetime(double month,
double day,
double year)
Construct a datetime instance using explicit values for each discrete
component of the date and with a time value of 0.
|
datetime(double month,
double day,
double year,
double hours,
double minutes)
Construct a datetime instance using explicit values for each discrete
component.
|
datetime(double month,
double day,
double year,
double hours,
double minutes,
double seconds)
Construct a datetime instance using explicit values for each discrete
component.
|
datetime(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.
|
datetime(NumberType month,
NumberType day,
NumberType year)
Construct a datetime instance using explicit values for each discrete
component of the date and with a time value of 0.
|
datetime(NumberType month,
NumberType day,
NumberType year,
NumberType hours,
NumberType minutes)
Construct a datetime instance using explicit values for each discrete
component.
|
datetime(NumberType month,
NumberType day,
NumberType year,
NumberType hours,
NumberType minutes,
NumberType seconds)
Construct a datetime instance using explicit values for each discrete
component.
|
datetime(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.
|
datetime(java.lang.String spec)
Creates a new instance from the given date and time specification.
|
datetime(java.lang.String spec,
java.lang.String format,
int windowingYear)
Converts a string to a datetime 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.
|
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.
|
java.util.Date |
dateValue()
Returns the current instance as an instance of the
Date
class which will accurately represent the UTC time that corresponds
to the current date in the timezone stored in this instance or
in the default timezone if the stored timezone is null . |
java.util.Date |
dateValue(java.util.TimeZone override)
Returns the current instance as an instance of the
Date
class which will accurately represent the UTC time that corresponds
to the current date in the timezone passed as a parameter or in the
default timezone if the passed timezone is null . |
void |
deepAssign(datetime 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.
|
static int64 |
differenceNum(datetime op1,
datetime op2)
Returns the number of milliseconds difference between the datetimes of two instances.
|
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 datetime |
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. |
protected void |
generateParsingError(int errCode)
Generate a parsing error.
|
protected long |
getAbsoluteTimeOffset()
Returns the absolute time in milliseconds since Java 'Epoch' or 0
if this is unknown.
|
int |
getHours()
Extract the hours time-element from this datetime.
|
int64 |
getHoursNum()
Extract the hours time-element from this datetime.
|
protected java.lang.String |
getIsoDate()
Obtains the text form of this date instance in ISO 8601 standard format.
|
int |
getMilliseconds()
Extract the milliseconds time-element from this datetime.
|
int64 |
getMillisecondsNum()
Extract the milliseconds time-element from this datetime.
|
int |
getMinutes()
Extract the minutes time-element from this datetime.
|
int64 |
getMinutesNum()
Extract the minutes time-element from this datetime.
|
int |
getSeconds()
Extract the seconds time-element from this datetime.
|
int64 |
getSecondsNum()
Extract the seconds time-element from this datetime.
|
int |
getTime()
Obtain the millis from midnight.
|
int64 |
getTimeNum()
Obtain the millis since midnight for this instance.
|
int |
getTzHours()
Obtains the hours of timezone offset.
|
int64 |
getTzHoursNum()
Obtains the hours of timezone offset.
|
int |
getTzMinutes()
Obtains the minutes of timezone offset.
|
int64 |
getTzMinutesNum()
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.
|
protected void |
instantiateFromDateTime(date d,
long time)
Worker to set the date (in the superclass) and the time (in this class)
given all the basic inputs.
|
protected void |
instantiateFromStringWorker(java.lang.String spec,
java.lang.String dateFormat,
int windowingYear)
Parses the given date and time specification and assigns the values into
the instance.
|
BaseDataType |
instantiateUnknown()
Creates a new instance of the same type that represents the
unknown value . |
static datetime |
instantiateUnknownDatetime()
Deprecated.
|
static integer |
millisecondsSinceMidnight()
Returns the time in milliseconds (MTIME, similar to TIME, which
returns seconds since midnight).
|
static integer |
millisecondsSinceMidnight(datetime dt)
Returns the time in milliseconds (MTIME, similar to TIME, which
returns seconds since midnight).
|
private static int |
millisSinceMidnight(java.util.Calendar cal)
Extract the portion of the calendar representing the number of
milliseconds since midnight.
|
static <T extends datetime> |
minusMillis(T dt,
long millis)
TODO: perhaps this should be moved to DateOps
Subtracts
milliseconds to the datetime of the left operand
and returns a new instance representing that datetime. |
static <T extends datetime> |
minusMillis(T dt,
NumberType millis)
TODO: perhaps this should be moved to DateOps
Subtracts
milliseconds to the datetime of the left operand
and returns a new instance representing that datetime. |
static datetime |
now()
Creates an instance that represents current date and time using the default timezone.
|
static <T extends datetime> |
plusMillis(T dt,
long millis)
TODO: perhaps this should be moved to DateOps
Adds
milliseconds to the datetime of the left operand and
returns a new instance representing that datetime. |
static <T extends datetime> |
plusMillis(T dt,
NumberType millis)
TODO: perhaps this should be moved to DateOps
Adds
milliseconds to the datetime of the left operand and
returns a new instance representing that datetime. |
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
void |
setTime(long millis)
Sets the milliseconds since midnight.
|
void |
setTime(long hours,
long mins,
long secs,
long millis)
Sets the internal time.
|
void |
setTime(NumberType millis)
Sets the millis from midnight.
|
void |
setTime(NumberType hours,
NumberType mins,
NumberType secs,
NumberType millis)
Sets the internal time.
|
protected void |
setTimeZoneOffset(long offset)
Set the offset in minutes from UTC for this instance and adjust to localtime.
|
datetime |
toLocalDatetime()
Return an object equal to this expressed in local time (current timezone offset).
|
java.lang.String |
toString(java.lang.String fmt)
Create a string representation of this date using a Progress 4GL style
date format string such as 99/99/99 HH:MM:SS.SSS or 99-99-9999 HH:MM:SS.SSS.
|
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").
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
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, main, 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, getTypeName, incompatibleTypesOnConversion, initializeDefaultExtent, instantiateDefaultExtent, isUnknownValue, maximum, minimum, notUnknownValue, sameType
changed, checkUndoable, checkUndoable, checkUndoable, getTransLevel, isGlobal, isUndoable, markUndoable, popBlock, rollback, setGlobal
public static final byte HOURS
public static final byte MINUTES
public static final byte SECONDS
public static final byte MILLIS
public static final byte AMPM
public static final byte TZ_HOURS
public static final byte TZ_MINS
private static final java.lang.String defaultFormat
private int time
public datetime()
public datetime(BaseDataType value)
assign(BaseDataType,boolean)
).value
- The value to be used for this instance.public datetime(java.util.Date d)
java.util.Date
instance.
WARNING: this will only work if the calendar in which this datetime
was constructed is the GregorianCalendar
AND if the
timezone in which this object was created is the same as the current
default for this JVM instance. If this is not correct then you
must use the datetime(Date,TimeZone)
version.
d
- The Date
instance from which to pattern the instance.public datetime(java.util.Date d, java.util.TimeZone zone)
java.util.Date
instance.d
- The Date
instance from which to pattern the instance.zone
- The TimeZone
for the calendar to be used for d
.public datetime(date d)
date
subclass.d
- The instance from which to copy state.public datetime(date d, NumberType time)
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.
d
- The date from which to copy.time
- The milliseconds since midnight.public datetime(date d, double time)
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.
d
- The date from which to copy.time
- The milliseconds since midnight.public datetime(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 datetime(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 datetime(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 datetime(double month, double day, double year)
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.public datetime(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 datetime(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 datetime(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 datetime(NumberType month, NumberType day, NumberType year)
unknown
input will result in an instance that is 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.public datetime(java.lang.String spec) throws ErrorConditionException
The specification must match the following format rules:
spec
- The date and time specification.ErrorConditionException
public datetime(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
datetime(String)
public datetime(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 static datetime now()
public static datetime 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[...]]]]where the date-separator can be either 't' or 'T'. The hours and minutes are mandatory in 2 digits and seconds 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.public static int64 differenceNum(datetime op1, datetime op2)
op1
- The left operand.op2
- The right operand (instance to subtract from the left operand).unknown value
if any input is unknown value
.public int64 getTimeNum()
TIME()
built-in function.public int getTime()
public void setTime(NumberType millis)
millis
- Milliseconds passed from midnight.public void setTime(long millis)
millis
- Milliseconds since midnight.public int getHours()
public int64 getHoursNum()
public int getMinutes()
public int64 getMinutesNum()
public int getSeconds()
public int64 getSecondsNum()
public int getMilliseconds()
public int64 getMillisecondsNum()
public int getTzMinutes()
public int getTzHours()
public int64 getTzMinutesNum()
public int64 getTzHoursNum()
public void setTime(NumberType hours, NumberType mins, NumberType secs, NumberType millis)
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.public void setTime(long hours, long mins, long secs, long millis)
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.public static <T extends datetime> T plusMillis(T dt, long millis)
milliseconds
to the datetime of the left operand and
returns a new instance representing that datetime.dt
- The left operand.millis
- The right operand (the number of milliseconds to add.
Note that this can be a negative number to effectively
subtract instead of add.millis
different from the
left operand or unknown value
if dt
is unknown value
.public static <T extends datetime> T plusMillis(T dt, NumberType millis)
milliseconds
to the datetime of the left operand and
returns a new instance representing that datetime.dt
- The left operand.millis
- The right operand (the number of milliseconds to add.
Note that this can be a negative number to effectively
subtract instead of add.millis
different from the
left operand or unknown value
if any input is
unknown value
.public static <T extends datetime> T minusMillis(T dt, long millis)
milliseconds
to the datetime of the left operand
and returns a new instance representing that datetime.dt
- The left operand.millis
- The right operand (the number of milliseconds to subtract.
Note that this can be a negative number to effectively
add instead of subtract.millis
different from the
left operand or unknown value
if dt
is unknown value
.public static <T extends datetime> T minusMillis(T dt, NumberType millis)
milliseconds
to the datetime of the left operand
and returns a new instance representing that datetime.dt
- The left operand.millis
- The right operand (the number of milliseconds to subtract.
Note that this can be a negative number to effectively
add instead of subtract.millis
different from the
left operand or unknown value
if any input is
unknown value
.public static integer millisecondsSinceMidnight()
public static integer millisecondsSinceMidnight(datetime dt)
dt
- the datetime or datetime-tz to evaluate.@Deprecated public static datetime instantiateUnknownDatetime()
datetime
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 date
unknown value
.public BaseDataType instantiateDefault()
instantiateDefault
in class date
public java.lang.String defaultFormatString()
defaultFormatString
in class date
public void assign(BaseDataType value, boolean force)
If the value is not of type datetime
, 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 date
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
) 00:00 is
assumed. Extra information available in datetimetz
(time-zone offset) is
ignored.assign
in class date
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(datetime 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.
public boolean equals(java.lang.Object o)
This implementation is consistent with hashCode()
.
equals
in class date
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 java.util.Date dateValue()
Date
class which will accurately represent the UTC time that corresponds
to the current date in the timezone stored in this instance or
in the default timezone if the stored timezone is null
.
WARNING: since the J2SE Date
class
implicitly encodes locale-specific time information along with date
information, the Date
object returned by this method is
sensitive to the environment in which it is interpreted
downstream. It is imperative therefore, when using the returned
Date
in downstream code, that the timezone of such code
(e.g., a date formatter or Calendar
instance) matches the
timezone stored in this date
instance (if the stored
timezone is null
, the JVM's default timezone should be used
in downstream code). Otherwise, the discrepancy in timezones (including
any Daylight Savings offset) may cause downstream code to interpret the
date information in the returned object incorrectly, typically as one
day earlier than expected.
public java.util.Date dateValue(java.util.TimeZone override)
Date
class which will accurately represent the UTC time that corresponds
to the current date in the timezone passed as a parameter or in the
default timezone if the passed timezone is null
.
WARNING: since the J2SE Date
class
implicitly encodes locale-specific time information along with date
information, the Date
object returned by this method is
sensitive to the environment in which it is interpreted
downstream. It is imperative therefore, when using the returned
Date
in downstream code, that the timezone of such code
(e.g., a date formatter or Calendar
instance) matches the
the override
parameter to this method (if
override
is null
, the JVM's default timezone
should be used in downstream code). Otherwise, the discrepancy in
timezones (including any Daylight Savings offset) may cause downstream
code to interpret the date information in the returned object
incorrectly, typically as one day earlier than expected.
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 date
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 date
public java.lang.String toString(java.lang.String fmt) throws java.lang.IllegalArgumentException
There are 2 (and only 2) cases where separator characters are not needed: '999999' and '99999999'. Any other format string without separator characters will cause an error to occur.
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 inside a 9 (if possible without losing data) or 99 format (but not a 999 format).
This implementation creates the given string based on the order of date components (e.g. MDY, YMD...) defined for this context.
toString
in class date
fmt
- The Progress style format string to use or null
to use the default obtained using defaultFormatString()
.java.lang.IllegalArgumentException
- If the format string passed is invalid.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class date
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 date
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public datetime toLocalDatetime()
protected java.lang.String getIsoDate()
getIsoDate
in class date
unknown
.protected long getAbsoluteTimeOffset()
getAbsoluteTimeOffset
in class date
protected void instantiateFromDateTime(date d, long time)
d
- The date instance to copy from.time
- Milliseconds since midnight.protected void generateParsingError(int errCode)
errCode
- The code of error to be raised.protected void instantiateFromStringWorker(java.lang.String spec, java.lang.String dateFormat, int windowingYear)
The specification must match the following format rules:
spec
string is empty or if it matches '?' (with no leading or trailing
spaces), an unknown datetime object is instantiated.instantiateFromStringWorker
in class date
spec
- The date and time specification.dateFormat
- The date format used for parsing. If it is null the default is used.windowingYear
- The windowing year used for 2 digits years. If it is negative the default is used.protected void setTimeZoneOffset(long offset)
instantiateFromStringWorker()
.offset
- The offset, must be between -840 and 840 inclusive.private static int millisSinceMidnight(java.util.Calendar cal)
cal
- The calendar instance to query.