public class JDFDate extends java.lang.Object implements java.lang.Comparable<java.lang.Object>, java.lang.Cloneable, java.util.Comparator<JDFDate>
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DATEISO |
static java.lang.String |
DATENUMERIC_DDMM |
static java.lang.String |
DATENUMERIC_MMDD |
static java.lang.String |
DATETIMEISO |
static java.lang.String |
DATETIMEISO_0
iso - seconds are 0
|
static java.lang.String |
DATETIMEISO_00
iso - seconds + minutes are 0
|
static java.lang.String |
DATETIMEISO_000
iso - seconds + minutes + hours are 0
|
static java.lang.String |
DATETIMEISO_MILLI |
static java.lang.String |
DATETIMENUMERIC_DDMM |
static java.lang.String |
DATETIMENUMERIC_MMDD |
static java.lang.String |
DATETIMEREADABLE |
| Constructor and Description |
|---|
JDFDate()
Allocates a
JDFDate object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond. |
JDFDate(JDFDate other) |
JDFDate(long iTime)
Allocates a
JDFDate object and initializes it so that it represents the time point, expressed in milliseconds after January 1, 1970, 0:00:00 GMT. |
JDFDate(java.lang.String strDateTime)
Allocates a
JDFDate object and initializes it so that the JDFDate represents a date set by strDateTime Format of strDateTime |
JDFDate(java.lang.String strDateTime,
int defaultHour,
int defaultMinute) |
| Modifier and Type | Method and Description |
|---|---|
JDFDate |
addOffset(int seconds,
int minutes,
int hours,
int days)
add a given offset to this
note: multiple calls stack |
boolean |
after(JDFDate other)
Deprecated.
use isLater
|
boolean |
after(long other)
true, if this is after other
|
boolean |
before(JDFDate other)
Deprecated.
use isEarlier
|
boolean |
before(long other)
true, if this is before other
|
JDFDate |
clone() |
int |
compare(JDFDate d0,
JDFDate d1) |
int |
compareTo(java.lang.Object arg0) |
static JDFDate |
createDate(java.lang.String date)
factory style constructor that catches all exceptions and returns null if date is invalid
|
JDFDate |
createDateFromDuration(JDFDuration duration,
int hour,
int minute)
create a date with a relative offset defined in duration
|
boolean |
equals(java.lang.Object other)
Compares two JDFDates for equality.
The result is true if and only if the argument is not null and is a JDFDate object that represents the same point in time, to the millisecond, as this
object. |
java.util.GregorianCalendar |
getCalendar() |
java.lang.String |
getDateISO()
the date formated as defined in ISO 8601
the date is in local time with the respective time zone specified |
java.lang.String |
getDateTime()
returns the date and time of this in none ISO pattern 'yyyyMMddHHmmss'
|
java.lang.String |
getDateTimeISO()
format the date and time as an ISO 8601 conform String
the date and time are in local time with the respective time zone specified |
java.lang.String |
getDateTimeISOBD()
Deprecated.
use @see
getDateISO() |
int |
getDay()
get the day of month as an integer
|
static int |
getDefaultHour() |
java.lang.String |
getFormattedDateTime(java.lang.String format)
returns the date and time of this in nonean arbitrary pattern
|
int |
getHour() |
int |
getMinute() |
int |
getMonth()
get the month as an integer
|
int |
getSecond() |
java.util.Date |
getTime()
Deprecated.
|
long |
getTimeInMillis()
get the time in milliseconds
|
java.lang.String |
getTimeISO()
format the time into a ISO conform String
the time is in local time |
java.lang.String |
getTimeZoneISO()
the TimeZone as spezified in ISO 8601 +/-10:00 for example
|
int |
getTimeZoneOffsetInMillis() |
int |
getYear()
get the year as an integer
|
int |
hashCode()
hashCode complements equals() to fulfill the equals/hashCode contract
|
boolean |
isEarlier(JDFDate x)
Tests if this date is before the specified date.
|
boolean |
isLater(JDFDate x)
Tests if this date is after the specified date.
|
static boolean |
isWantISOMilliseconds() |
static void |
setDefaultHour(int defaultHour)
Setter for defaultHour attribute.
|
void |
setOffset(int iOffset)
Deprecated.
use addOffset
|
void |
setTime(java.util.Date date)
Deprecated.
|
JDFDate |
setTime(int h,
int m,
int s)
set the time without modifying the date
|
JDFDate |
setTimeInMillis(long l)
set this time milliseconds
|
JDFDate |
setTimeZoneOffsetInMillis(int timeZoneOffsetInMillis) |
static void |
setWantISOMilliseconds(boolean wantISOMilliseconds) |
java.lang.String |
toString()
for debug purpose
|
public static final java.lang.String DATEISO
public static final java.lang.String DATETIMEISO
public static final java.lang.String DATETIMEISO_MILLI
public static final java.lang.String DATETIMEISO_0
public static final java.lang.String DATETIMEISO_00
public static final java.lang.String DATETIMEISO_000
public static final java.lang.String DATETIMEREADABLE
public static final java.lang.String DATENUMERIC_DDMM
public static final java.lang.String DATENUMERIC_MMDD
public static final java.lang.String DATETIMENUMERIC_DDMM
public static final java.lang.String DATETIMENUMERIC_MMDD
public JDFDate()
JDFDate object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond. Also sets the current time zone to the
system default time zonepublic JDFDate(long iTime)
JDFDate object and initializes it so that it represents the time point, expressed in milliseconds after January 1, 1970, 0:00:00 GMT. Also sets the current time zone to
the system default time zoneiTime - current time in milliseconds after January 1, 1970, 0:00:00 GMT. Use JDFDuration instead. This class will be modified to handle only JDFDate objectspublic JDFDate(JDFDate other)
other - the date to clonepublic JDFDate(java.lang.String strDateTime)
throws java.util.zip.DataFormatException
JDFDate object and initializes it so that the JDFDate represents a date set by strDateTime Format of strDateTime
Valid DataTime Strings are:
Attention!
you can enter milliseconds, but getDateTimeISO() still returns the time rounded to full seconds. Only long getTimeInMillis() returns the exact time
strDateTime - formatted date and timejava.util.zip.DataFormatException - if strDateTime is not a valid DateTime
Attention! you can enter milliseconds, but getDateTimeISO() still returns the time rounded to full seconds only long getTimeInMillis() returns the exact timepublic JDFDate(java.lang.String strDateTime,
int defaultHour,
int defaultMinute)
throws java.util.zip.DataFormatException
java.util.zip.DataFormatExceptionpublic static boolean isWantISOMilliseconds()
public static void setWantISOMilliseconds(boolean wantISOMilliseconds)
wantISOMilliseconds - the wantISOMilliseconds to setpublic static void setDefaultHour(int defaultHour)
defaultHour - the defaultHour to setpublic static int getDefaultHour()
public static JDFDate createDate(java.lang.String date)
date - the formatted date stringpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getFormattedDateTime(java.lang.String format)
format - the format string using FastDateFormat formattingjava.lang.IllegalArgumentExceptionpublic java.lang.String getDateTime()
@Deprecated public void setOffset(int iOffset)
iOffset - offset time in secondspublic JDFDate addOffset(int seconds, int minutes, int hours, int days)
seconds - seconds to add to thisminutes - minutes to add to thishours - hours to add to thisdays - days to add to thispublic JDFDate createDateFromDuration(JDFDuration duration, int hour, int minute)
duration - hour - the fixed hour, if -1 don't setminute - the fixed minute, if -1 don't setpublic java.lang.String getDateTimeISO()
@Deprecated public java.lang.String getDateTimeISOBD()
getDateISO()public java.lang.String getDateISO()
public java.lang.String getTimeISO()
public java.lang.String getTimeZoneISO()
public boolean isLater(JDFDate x)
x - the date you wish to know if it is later than thispublic boolean isEarlier(JDFDate x)
x - the date you wish to know if it is eariler than thispublic long getTimeInMillis()
public JDFDate setTimeInMillis(long l)
l - time in millisecondspublic java.util.GregorianCalendar getCalendar()
public JDFDate setTime(int h, int m, int s)
h - m - s - @Deprecated public boolean before(JDFDate other)
other - the time in milliseconds since 1970 (e.g. from System.currentTimeMillis())public boolean before(long other)
other - the time in milliseconds since 1970 (e.g. from System.currentTimeMillis())@Deprecated public boolean after(JDFDate other)
other - public boolean after(long other)
other - the time in milliseconds since 1970 (e.g. from System.currentTimeMillis())@Deprecated public java.util.Date getTime()
public int getMonth()
public int getYear()
public int getDay()
@Deprecated public void setTime(java.util.Date date)
date - public boolean equals(java.lang.Object other)
true if and only if the argument is not null and is a JDFDate object that represents the same point in time, to the millisecond, as this
object.
Thus, two JDFDate objects are equal if and only if the getTimeInMillis method returns the same long value for both.
equals in interface java.util.Comparator<JDFDate>equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(java.lang.Object arg0)
compareTo in interface java.lang.Comparable<java.lang.Object>the value 0 if the argument is a Date equal to this Date; a value less than 0 if the argument is a Date after this Date; and a value
greater than 0 if the argument is a Date before this Date.public JDFDate setTimeZoneOffsetInMillis(int timeZoneOffsetInMillis)
timeZoneOffsetInMillis - The timeZoneOffsetInMillis to set.public int getTimeZoneOffsetInMillis()
public JDFDate clone()
clone in class java.lang.ObjectObject.clone()public int compare(JDFDate d0, JDFDate d1)
compare in interface java.util.Comparator<JDFDate>d0 - d1 - Comparator.compare(java.lang.Object, java.lang.Object)public int getHour()
public int getMinute()
public int getSecond()