public class JDFDate extends Object implements Comparable<Object>, Cloneable, Comparator<JDFDate>
Modifier and Type | Field and Description |
---|---|
static String |
DATEISO |
static String |
DATENUMERIC_DDMM |
static String |
DATENUMERIC_MMDD |
static String |
DATETIMEISO |
static String |
DATETIMEISO_0
iso - seconds are 0
|
static String |
DATETIMEISO_00
iso - seconds + minutes are 0
|
static String |
DATETIMEISO_000
iso - seconds + minutes + hours are 0
|
static String |
DATETIMENUMERIC_DDMM |
static String |
DATETIMENUMERIC_MMDD |
static 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(String strDateTime)
Allocates a
JDFDate object and initializes it so that the JDFDate represents a date set by strDateTime Format of
strDateTime
Valid DataTime Strings are:
"yyyy-mm-ddThh:mm:ss.sss+hh:00"
"yyyy-mm-ddThh:mm:ss+hh:00"
"yyyy-mm-ddThh:mm:ss-hh:00"
"yyyy-mm-ddThh:mm:ssZ"
Attention! |
JDFDate(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(Object arg0) |
static JDFDate |
createDate(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(Object other)
Compares two JDFDates for equality.
|
GregorianCalendar |
getCalendar() |
String |
getDateISO()
the date formated as defined in ISO 8601
the date is in local time with the respective time zone specified |
String |
getDateTime()
returns the date and time of this in none ISO pattern 'yyyyMMddHHmmss'
|
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 |
String |
getDateTimeISOBD()
Deprecated.
use @see
getDateISO() |
int |
getDay()
get the day of month as an integer
|
String |
getFormattedDateTime(String format)
returns the date and time of this in nonean arbitrary pattern
|
int |
getMonth()
get the month as an integer
|
Date |
getTime()
Deprecated.
|
long |
getTimeInMillis()
get the time in milliseconds
|
String |
getTimeISO()
format the time into a ISO conform String
the time is in local time |
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 void |
setDefaultHour(int defaultHour)
Setter for defaultHour attribute.
|
void |
setOffset(int iOffset)
Deprecated.
use addOffset
|
void |
setTime(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) |
String |
toString()
for debug purpose
|
finalize, getClass, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public static final String DATEISO
public static final String DATETIMEISO
public static final String DATETIMEISO_0
public static final String DATETIMEISO_00
public static final String DATETIMEISO_000
public static final String DATETIMEREADABLE
public static final String DATENUMERIC_DDMM
public static final String DATENUMERIC_MMDD
public static final String DATETIMENUMERIC_DDMM
public static final 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(String strDateTime) throws 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 timeDataFormatException
- 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(String strDateTime, int defaultHour, int defaultMinute) throws DataFormatException
DataFormatException
public static void setDefaultHour(int defaultHour)
defaultHour
- the defaultHour to setpublic static JDFDate createDate(String date)
date
- the formatted date stringpublic String toString()
public String getFormattedDateTime(String format)
format
- the format string using FastDateFormat
formattingIllegalArgumentException
public 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 String getDateTimeISO()
@Deprecated public String getDateTimeISOBD()
getDateISO()
public String getDateISO()
public String getTimeISO()
public 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 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 Date getTime()
public int getMonth()
public int getYear()
public int getDay()
@Deprecated public void setTime(Date date)
date
- public boolean equals(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 Comparator<JDFDate>
equals
in class Object
public int hashCode()
public int compareTo(Object arg0)
public JDFDate setTimeZoneOffsetInMillis(int timeZoneOffsetInMillis)
timeZoneOffsetInMillis
- The timeZoneOffsetInMillis to set.public int getTimeZoneOffsetInMillis()
public JDFDate clone()
clone
in class Object
Object.clone()
public int compare(JDFDate d0, JDFDate d1)
compare
in interface Comparator<JDFDate>
d0
- d1
- Comparator.compare(java.lang.Object, java.lang.Object)
Copyright © 2018. All rights reserved.