public class JDateTime
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable, java.io.Serializable
The Julian day or Julian day number (JDN) is the (integer) number of days that have elapsed since Monday, January 1, 4713 BC in the proleptic Julian calendar 1. That day is counted as Julian day zero. Thus the multiples of 7 are Mondays. Negative values can also be used.
The Julian Date (JD) is the number of days (with decimal fraction of the day) that have elapsed since 12 noon Greenwich Mean Time (UT or TT) of that day. Rounding to the nearest integer gives the Julian day number.
JDateTime
contains date/time information for current day. By
default, behaviour and formats are set to ISO standard, although this may
be changed.
JDateTime
can be set in many different ways by using setXxx()
methods or equivalent constructors. Moreover, date time information may be loaded from an instance
of any available java date-time class. This functionality can be easily
enhanced for any custom date/time class. Furthermore, JDateTime
can be converted to any such date/time class.
Rolling dates with JDateTime
is easy. For this
JDateTime
contains many addXxx()
methods. Time can be added
or subtracted with any value or more values at once. All combinations are
valid. Calculations also performs month fixes by default.
JDateTime
behaviour is set by several attributes (or
parameters). Each one contains 2 values: one is the default value, used by
all instances of JDateTime
and the other one is just for a
specific instance of JDateTime
. This means that it is
possible to set behaviour of all instances at once or of one particular
instance.
Bellow is the list of behaviour attributes:
JDateTime
will
additionally fix all time adding and fix the date. For example, adding
one month to 2003-01-31 will give 2003-02-28 and not 2003-03-03.
By default, monthFix is turned on and set to true
.
JdtFormatter
parses and uses this template.JDateTime
works significantly faster then java's Calendar
s. Since
JDateTime
doesn't use lazy initialization, setXxx() method is
slower. However, this doesn't have much effect to the global performances:
settings are usually not used without gettings:) As soon as any other method is
used (getXxx() or addXxx()) performances of JDateTime
becomes
significantly better.
Year 1582 is (almost:) working: after 1582-10-04 (Thursday) is 1582-10-15 (Friday). Users must be aware of this when doing time rolling before across this period.
More info: Julian Date on Wikipedia
Modifier and Type | Field and Description |
---|---|
static int |
APRIL |
static int |
AUGUST |
protected int |
dayofweek
Day of week, range: [1-7] == [Monday - Sunday]
|
protected int |
dayofyear
Day of year, range: [1-365] or [1-366]
|
static int |
DECEMBER |
static java.lang.String |
DEFAULT_FORMAT |
static int |
FEBRUARY |
protected int |
firstDayOfWeek |
protected java.lang.String |
format |
static int |
FRIDAY |
static int |
JANUARY |
static JulianDateStamp |
JD_1970
Julian Date for 1970-01-01T00:00:00 (Thursday).
|
static JulianDateStamp |
JD_2001
Julian Date for 2001-01-01T00:00:00 (Monday).
|
protected JulianDateStamp |
jdate
Current Julian Date.
|
protected JdtFormatter |
jdtFormatter |
static int |
JULY |
static int |
JUNE |
protected boolean |
leap
Leap year flag.
|
protected java.util.Locale |
locale |
static int |
MARCH |
static int |
MAY |
protected int |
minDaysInFirstWeek |
static int |
MONDAY |
protected boolean |
monthFix |
protected int |
mustHaveDayOfFirstWeek |
static int |
NOVEMBER |
static int |
OCTOBER |
static int |
SATURDAY |
static int |
SEPTEMBER |
static int |
SUNDAY |
static int |
THURSDAY |
protected DateTimeStamp |
time
DateTimeStamp for current date. |
protected java.util.TimeZone |
timezone |
protected boolean |
trackDST |
static int |
TUESDAY |
static int |
WEDNESDAY |
protected int |
weekofmonth
Week of month.
|
protected int |
weekofyear
Week of year, range: [1-52] or [1-53]
|
Constructor and Description |
---|
JDateTime()
Constructor that sets current local date and time.
|
JDateTime(java.util.Calendar calendar)
Creates
JDateTime from Calendar . |
JDateTime(java.util.Date date)
Creates
JDateTime from Date . |
JDateTime(DateTimeStamp dts)
Creates
JDateTime from DateTimeStamp . |
JDateTime(double jd)
Creates
JDateTime from double that represents JD. |
JDateTime(int year,
int month,
int day)
Constructor that sets just date.
|
JDateTime(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Constructor that set date and time.
|
JDateTime(JulianDateStamp jds)
Creates
JDateTime from JulianDateStamp . |
JDateTime(long millis)
Constructor that sets current time specified as time in milliseconds, from
the midnight, January 1, 1970 UTC.
|
JDateTime(java.lang.String src)
Creates
JDateTime from a string. |
JDateTime(java.lang.String src,
JdtFormat jdtFormat) |
JDateTime(java.lang.String src,
java.lang.String template)
Creates
JDateTime from a string, using specified template. |
Modifier and Type | Method and Description |
---|---|
JDateTime |
add(int year,
int month,
int day)
Adds date, leaving time unchanged, with preset value of monthFix.
|
JDateTime |
add(int year,
int month,
int day,
boolean monthFix)
Adds date, leaving time unchanged.
|
JDateTime |
add(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Performs time adding with preset value of monthFix attribute.
|
JDateTime |
add(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
boolean monthFix)
Adds time to current time.
|
JDateTime |
addDay(int d)
Adds days, with preset value of monthFix.
|
JDateTime |
addDay(int d,
boolean monthFix)
Adds days.
|
JDateTime |
addHour(int h)
Adds hours, with preset value of monthFix.
|
JDateTime |
addHour(int h,
boolean monthFix)
Adds hours.
|
JDateTime |
addMillisecond(int ms)
Adds milliseconds, with preset value of monthFix.
|
JDateTime |
addMillisecond(int ms,
boolean monthFix)
Adds milliseconds.
|
JDateTime |
addMinute(int m)
Adds minutes, with preset value of monthFix.
|
JDateTime |
addMinute(int m,
boolean monthFix)
Adds minutes.
|
JDateTime |
addMonth(int m)
Adds month, with preset value of monthFix.
|
JDateTime |
addMonth(int m,
boolean monthFix)
Adds month.
|
protected void |
addNoDST(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
boolean monthFix) |
JDateTime |
addSecond(int s)
Adds seconds, with preset value of monthFix.
|
JDateTime |
addSecond(int s,
boolean monthFix)
Adds seconds.
|
JDateTime |
addTime(int hour,
int minute,
int second) |
JDateTime |
addTime(int hour,
int minute,
int second,
boolean monthFix) |
JDateTime |
addTime(int hour,
int minute,
int second,
int millisecond)
Adds time, with preset value of monthFix.
|
JDateTime |
addTime(int hour,
int minute,
int second,
int millisecond,
boolean monthFix)
Adds time.
|
JDateTime |
addYear(int y)
Adds year, with preset value of monthFix.
|
JDateTime |
addYear(int y,
boolean monthFix)
Adds year.
|
JDateTime |
changeTimeZone(java.util.TimeZone timezone)
Changes current timezone.
|
JDateTime |
changeTimeZone(java.util.TimeZone from,
java.util.TimeZone to)
Changes time zone.
|
JDateTime |
clone() |
int |
compareDateTo(JDateTime jd)
Compares current JDateTime date with another date.
|
int |
compareTo(JDateTime jd) |
int |
compareTo(java.lang.Object o)
Compares current JDateTime object with another one, up to 1 millisecond.
|
java.util.Calendar |
convertToCalendar()
Converts to
Calendar instance. |
java.util.Date |
convertToDate()
Converts to
Date instance. |
java.sql.Date |
convertToSqlDate()
Converts to
java.sql.Date instance. |
java.sql.Time |
convertToSqlTime()
Converts to
Time instance. |
java.sql.Timestamp |
convertToSqlTimestamp()
Converts to
Timestamp instance. |
int |
daysBetween(JDateTime then)
Returns number of full days between two dates.
|
int |
daysBetween(JulianDateStamp then)
Returns number of full days between two dates.
|
boolean |
equals(java.lang.Object obj)
Compares if two JDateTime instances are equal.
|
boolean |
equalsDate(int year,
int month,
int day)
Returns
true if provided date is equal to current one. |
boolean |
equalsDate(JDateTime date)
Returns
true if two dates are equal. |
boolean |
equalsTime(JDateTime date)
Returns
true if two times are equal. |
DateTimeStamp |
getDateTimeStamp()
Returns current
DateTimeStamp . |
int |
getDay()
Returns current day of month.
|
int |
getDayOfMonth()
Returns current day of month.
|
int |
getDayOfWeek()
Returns current day of week.
|
int |
getDayOfYear()
Returns current day of year.
|
int |
getEra()
Returns era: AD(1) or BC(0).
|
int |
getFirstDayOfWeek()
Returns actual the first day of the week.
|
java.lang.String |
getFormat()
Returns format.
|
int |
getHour()
Returns current hour.
|
JdtFormatter |
getJdtFormatter()
Returns actual
JdtFormatter . |
JulianDateStamp |
getJulianDate()
Returns
JulianDateStamp . |
double |
getJulianDateDouble()
Returns JD as double value.
|
int |
getJulianDayNumber()
Returns JDN.
|
java.util.Locale |
getLocale()
Return currently active locale.
|
int |
getMillisecond()
Returns current milliseconds.
|
int |
getMillisOfDay()
Calculates the number of milliseconds of a day.
|
int |
getMinDaysInFirstWeek()
Returns actual minimal number of days of the first week.
|
int |
getMinute()
Returns current minutes.
|
int |
getMonth()
Returns current month.
|
int |
getMonthLength()
Returns the length of the current month in days.
|
int |
getMonthLength(int month)
Returns the length of the specified month in days.
|
int |
getMustHaveDayOfFirstWeek()
Returns actual must have day of the 1st week.
|
int |
getSecond()
Return current seconds.
|
long |
getTimeInMillis()
Returns time based on current time in milliseconds.
|
java.util.TimeZone |
getTimeZone()
Return currently active time zone.
|
int |
getWeekOfMonth()
Returns current week of month.
|
int |
getWeekOfYear()
Returns current week of year.
|
int |
getYear()
Returns current year.
|
int |
hashCode() |
boolean |
isAfter(JDateTime then)
Returns
true if current time is after then provided time. |
boolean |
isAfterDate(JDateTime then)
Returns
true if current date is after then provided date. |
boolean |
isBefore(JDateTime then)
Returns
true if current time is before then provided time. |
boolean |
isBeforeDate(JDateTime then)
Returns
true if current date is before then provided date. |
boolean |
isInDaylightTime()
Returns
true if current date is in
daylight savings time in the time zone. |
boolean |
isLeapYear()
Returns
true if current year is leap year. |
boolean |
isMonthFix()
Returns
true if month fix is active. |
boolean |
isTrackDST() |
boolean |
isValid(java.lang.String s)
Checks if some string represents a valid date using actual template.
|
boolean |
isValid(java.lang.String s,
java.lang.String template)
Checks if some string represents a valid date using provided template.
|
JDateTime |
parse(java.lang.String src)
Sets date/time from a string and currently active template.
|
JDateTime |
parse(java.lang.String src,
JdtFormat jdtFormat) |
JDateTime |
parse(java.lang.String src,
java.lang.String format)
Sets date/time from a string given in provided template.
|
JDateTime |
set(int year,
int month,
int day)
Sets date, time is set to midnight (00:00:00.000).
|
JDateTime |
set(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Core method that sets date and time.
|
JDateTime |
setCurrentTime()
Sets current local date and time.
|
JDateTime |
setDate(int year,
int month,
int day)
Sets date, time remains unchanged.
|
JDateTime |
setDateTime(java.util.Calendar calendar)
Sets current date and time from
Calendar . |
JDateTime |
setDateTime(java.util.Date date)
Sets current date and time from
Date . |
JDateTime |
setDateTimeStamp(DateTimeStamp dts)
Loads current date time information.
|
JDateTime |
setDay(int d)
Sets current day of month.
|
JDateTime |
setFormat(java.lang.String format)
Defines default format.
|
JDateTime |
setHour(int h)
Set current hour.
|
JDateTime |
setJdtFormat(JdtFormat jdtFormat)
Sets both format and formatter from provided
JdtFormat . |
JDateTime |
setJdtFormatter(JdtFormatter jdtFormatter)
Defines custom formatter.
|
JDateTime |
setJulianDate(double jd)
Sets JD.
|
JDateTime |
setJulianDate(JulianDateStamp jds)
Sets current Julian Date.
|
JDateTime |
setLocale(java.util.Locale locale)
Sets custom locale.
|
JDateTime |
setMillisecond(int m)
Sets current millisecond.
|
JDateTime |
setMinute(int m)
Set current minute.
|
JDateTime |
setMonth(int m)
Sets current month.
|
JDateTime |
setMonthFix(boolean monthFix)
Sets custom month fix value.
|
JDateTime |
setSecond(int s)
Sets current second.
|
JDateTime |
setSecond(int s,
int m) |
JDateTime |
setTime(int hour,
int minute,
int second,
int millisecond)
Sets time, date is unchanged.
|
JDateTime |
setTimeInMillis(long millis)
Sets the time based on current time in milliseconds.
|
JDateTime |
setTimeZone(java.util.TimeZone timezone)
Sets time zone without changing the time.
|
JDateTime |
setTrackDST(boolean trackDST) |
JDateTime |
setWeekDefinition(int start,
int must)
Defines week definitions.
|
JDateTime |
setWeekDefinitionAlt(int start,
int min)
Defines week alternatively.
|
JDateTime |
setYear(int y)
Sets current year.
|
JDateTime |
sub(int year,
int month,
int day) |
JDateTime |
sub(int year,
int month,
int day,
boolean monthFix) |
JDateTime |
sub(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond) |
JDateTime |
sub(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
boolean monthFix) |
JDateTime |
subDay(int d) |
JDateTime |
subDay(int d,
boolean monthFix) |
JDateTime |
subHour(int h) |
JDateTime |
subHour(int h,
boolean monthFix) |
JDateTime |
subMillisecond(int ms) |
JDateTime |
subMillisecond(int ms,
boolean monthFix) |
JDateTime |
subMinute(int m) |
JDateTime |
subMinute(int m,
boolean monthFix) |
JDateTime |
subMonth(int m) |
JDateTime |
subMonth(int m,
boolean monthFix) |
JDateTime |
subSecond(int s) |
JDateTime |
subSecond(int s,
boolean monthFix) |
JDateTime |
subTime(int hour,
int minute,
int second) |
JDateTime |
subTime(int hour,
int minute,
int second,
boolean monthFix) |
JDateTime |
subTime(int hour,
int minute,
int second,
int millisecond) |
JDateTime |
subTime(int hour,
int minute,
int second,
int millisecond,
boolean monthFix) |
JDateTime |
subYear(int y) |
JDateTime |
subYear(int y,
boolean monthFix) |
java.lang.String |
toString()
Returns spring representation of current date/time in currently active format.
|
java.lang.String |
toString(JdtFormat jdtFormat) |
java.lang.String |
toString(java.lang.String format)
Returns string representation of date/time in specified format.
|
public static final java.lang.String DEFAULT_FORMAT
public static final int MONDAY
public static final int TUESDAY
public static final int WEDNESDAY
public static final int THURSDAY
public static final int FRIDAY
public static final int SATURDAY
public static final int SUNDAY
public static final int JANUARY
public static final int FEBRUARY
public static final int MARCH
public static final int APRIL
public static final int MAY
public static final int JUNE
public static final int JULY
public static final int AUGUST
public static final int SEPTEMBER
public static final int OCTOBER
public static final int NOVEMBER
public static final int DECEMBER
protected DateTimeStamp time
DateTimeStamp
for current date.protected int dayofweek
protected int dayofyear
protected boolean leap
protected int weekofyear
protected int weekofmonth
protected JulianDateStamp jdate
public static final JulianDateStamp JD_1970
public static final JulianDateStamp JD_2001
protected boolean trackDST
protected boolean monthFix
protected java.util.TimeZone timezone
protected java.util.Locale locale
protected java.lang.String format
protected JdtFormatter jdtFormatter
protected int firstDayOfWeek
protected int mustHaveDayOfFirstWeek
protected int minDaysInFirstWeek
public JDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)
year
- year to setmonth
- month to setday
- day to sethour
- hours to setminute
- minutes to setsecond
- seconds to setmillisecond
- milliseconds to setset(int, int, int, int, int, int, int)
public JDateTime(int year, int month, int day)
year
- year to setmonth
- month to setday
- day to setset(int, int, int)
public JDateTime(long millis)
millis
- time in milliseconds, from the midnight, January 1, 1970 UTCsetTimeInMillis(long )
public JDateTime()
public JDateTime(java.util.Calendar calendar)
JDateTime
from Calendar
.public JDateTime(java.util.Date date)
JDateTime
from Date
.public JDateTime(DateTimeStamp dts)
JDateTime
from DateTimeStamp
.public JDateTime(JulianDateStamp jds)
JDateTime
from JulianDateStamp
.public JDateTime(double jd)
JDateTime
from double
that represents JD.public JDateTime(java.lang.String src)
JDateTime
from a string.public JDateTime(java.lang.String src, java.lang.String template)
JDateTime
from a string, using specified template.public JDateTime(java.lang.String src, JdtFormat jdtFormat)
public DateTimeStamp getDateTimeStamp()
DateTimeStamp
.
Returned instance is still used internally (i.e. it is not cloned before returning).public JDateTime setDateTimeStamp(DateTimeStamp dts)
public JDateTime setJulianDate(JulianDateStamp jds)
jds
- current julian datepublic JulianDateStamp getJulianDate()
JulianDateStamp
. It is the same instance used internally.public int getJulianDayNumber()
public JDateTime set(int year, int month, int day, int hour, int minute, int second, int millisecond)
year
- year to setmonth
- month to setday
- day to sethour
- hour to setminute
- minute to setsecond
- second to setpublic JDateTime add(int year, int month, int day, int hour, int minute, int second, int millisecond, boolean monthFix)
There are 2 different kinds of addings, when months are added:
year
- delta yearmonth
- delta monthday
- delta dayshour
- delta hoursminute
- delta minutessecond
- delta secondsmonthFix
- true
for month fixing, false
otherwiseprotected void addNoDST(int year, int month, int day, int hour, int minute, int second, int millisecond, boolean monthFix)
public JDateTime sub(int year, int month, int day, int hour, int minute, int second, int millisecond, boolean monthFix)
public JDateTime add(int year, int month, int day, int hour, int minute, int second, int millisecond)
year
- delta yearmonth
- delta monthday
- delta dayshour
- delta hoursminute
- delta minutessecond
- delta secondsadd(int, int, int, int, int, int, int, boolean)
public JDateTime sub(int year, int month, int day, int hour, int minute, int second, int millisecond)
public JDateTime add(int year, int month, int day, boolean monthFix)
year
- years to addmonth
- months to addday
- days to addmonthFix
- true
for month fixing, false
otherwiseadd(int, int, int, int, int, int, int, boolean)
public JDateTime sub(int year, int month, int day, boolean monthFix)
public JDateTime add(int year, int month, int day)
year
- years to addmonth
- months to addday
- days to addadd(int, int, int, boolean)
public JDateTime sub(int year, int month, int day)
public JDateTime addTime(int hour, int minute, int second, int millisecond, boolean monthFix)
hour
- hours to addminute
- minutes to addsecond
- seconds to addmonthFix
- true
for month fixing, false
otherwiseadd(int, int, int, int, int, int, int)
public JDateTime subTime(int hour, int minute, int second, int millisecond, boolean monthFix)
public JDateTime addTime(int hour, int minute, int second, boolean monthFix)
public JDateTime subTime(int hour, int minute, int second, boolean monthFix)
public JDateTime addTime(int hour, int minute, int second, int millisecond)
hour
- hours to addminute
- minutes to addsecond
- seconds to addaddTime(int, int, int, int, boolean)
public JDateTime subTime(int hour, int minute, int second, int millisecond)
public JDateTime addTime(int hour, int minute, int second)
public JDateTime subTime(int hour, int minute, int second)
public JDateTime addYear(int y, boolean monthFix)
y
- year to addmonthFix
- true
for month fixing, false
otherwisepublic JDateTime subYear(int y, boolean monthFix)
public JDateTime addYear(int y)
y
- year to addpublic JDateTime subYear(int y)
public JDateTime addMonth(int m, boolean monthFix)
m
- month to addmonthFix
- true
for month fixing, false
otherwisepublic JDateTime subMonth(int m, boolean monthFix)
public JDateTime addMonth(int m)
m
- month to addpublic JDateTime subMonth(int m)
public JDateTime addDay(int d, boolean monthFix)
d
- days to addmonthFix
- true
for month fixing, false
otherwisepublic JDateTime subDay(int d, boolean monthFix)
public JDateTime addDay(int d)
d
- days to addpublic JDateTime subDay(int d)
public JDateTime addHour(int h, boolean monthFix)
h
- hours to addmonthFix
- true
for month fixing, false
otherwisepublic JDateTime subHour(int h, boolean monthFix)
public JDateTime addHour(int h)
h
- hours to addpublic JDateTime subHour(int h)
public JDateTime addMinute(int m, boolean monthFix)
m
- minutes to add.monthFix
- true
for month fixing, false
otherwisepublic JDateTime subMinute(int m, boolean monthFix)
public JDateTime addMinute(int m)
m
- minutes to add.public JDateTime subMinute(int m)
public JDateTime addSecond(int s, boolean monthFix)
s
- seconds to addmonthFix
- true
for month fixing, false
otherwisepublic JDateTime subSecond(int s, boolean monthFix)
public JDateTime addSecond(int s)
s
- seconds to addpublic JDateTime subSecond(int s)
public JDateTime addMillisecond(int ms, boolean monthFix)
ms
- milliseconds to addmonthFix
- true
for month fixing, false
otherwisepublic JDateTime subMillisecond(int ms, boolean monthFix)
public JDateTime addMillisecond(int ms)
ms
- milliseconds to addpublic JDateTime subMillisecond(int ms)
public JDateTime set(int year, int month, int day)
year
- year to setmonth
- month to setday
- day to setpublic JDateTime setTime(int hour, int minute, int second, int millisecond)
hour
- hours to setminute
- minutes to setsecond
- seconds to setpublic JDateTime setDate(int year, int month, int day)
year
- yearmonth
- monthday
- daypublic JDateTime setTimeInMillis(long millis)
Calculation is divided in two steps, due to precision issues.
millis
- time in milliseconds, from the midnight, January 1, 1970 UTCpublic long getTimeInMillis()
Due to possible huge values calculation is divided in two steps: first for fractional difference, and then for integer parts.
public JDateTime setYear(int y)
y
- year to setpublic JDateTime setMonth(int m)
m
- month to setpublic JDateTime setDay(int d)
d
- day to setpublic JDateTime setHour(int h)
h
- hour to setpublic JDateTime setMinute(int m)
m
- minutes to setpublic JDateTime setSecond(int s)
s
- seconds and milliseconds to setpublic JDateTime setSecond(int s, int m)
public JDateTime setMillisecond(int m)
m
- milliseconds to setpublic int getYear()
public int getMonth()
public int getDay()
getDayOfMonth()
public int getDayOfMonth()
getDay()
public int getHour()
public int getMinute()
public int getSecond()
public int getMillisecond()
public int getDayOfWeek()
public int getDayOfYear()
public boolean isLeapYear()
true
if current year is leap year.public int getWeekOfYear()
public int getWeekOfMonth()
public int getMonthLength(int month)
public int getMonthLength()
public int getEra()
public int getMillisOfDay()
public JDateTime setCurrentTime()
public JDateTime setDateTime(java.util.Calendar calendar)
Calendar
.public JDateTime setDateTime(java.util.Date date)
Date
.public java.util.Date convertToDate()
Date
instance.public java.util.Calendar convertToCalendar()
Calendar
instance.public java.sql.Date convertToSqlDate()
java.sql.Date
instance.public java.sql.Time convertToSqlTime()
Time
instance.public java.sql.Timestamp convertToSqlTimestamp()
Timestamp
instance.public boolean isTrackDST()
public JDateTime setTrackDST(boolean trackDST)
public boolean isMonthFix()
true
if month fix is active.public JDateTime setMonthFix(boolean monthFix)
public JDateTime changeTimeZone(java.util.TimeZone timezone)
public JDateTime changeTimeZone(java.util.TimeZone from, java.util.TimeZone to)
setTimeZone(from); changeTimeZone(to);
public JDateTime setTimeZone(java.util.TimeZone timezone)
public java.util.TimeZone getTimeZone()
public boolean isInDaylightTime()
true
if current date is in
daylight savings time in the time zone.public JDateTime setLocale(java.util.Locale locale)
public java.util.Locale getLocale()
public JDateTime setFormat(java.lang.String format)
public java.lang.String getFormat()
public JDateTime setJdtFormatter(JdtFormatter jdtFormatter)
public JdtFormatter getJdtFormatter()
JdtFormatter
.public JDateTime setJdtFormat(JdtFormat jdtFormat)
JdtFormat
.public java.lang.String toString(java.lang.String format)
public java.lang.String toString()
toString
in class java.lang.Object
getFormat()
public java.lang.String toString(JdtFormat jdtFormat)
public JDateTime parse(java.lang.String src, java.lang.String format)
src
- string containing date time informationformat
- format templatepublic JDateTime parse(java.lang.String src)
src
- string containing date time informationgetFormat()
public boolean isValid(java.lang.String s)
true
if date is valid, otherwise false
public boolean isValid(java.lang.String s, java.lang.String template)
true
if date is valid, otherwise false
public JDateTime setWeekDefinition(int start, int must)
start
- first day in week, [1-7],must
- must have day of the 1st week, [1-7]public int getFirstDayOfWeek()
public int getMustHaveDayOfFirstWeek()
public int getMinDaysInFirstWeek()
public JDateTime setWeekDefinitionAlt(int start, int min)
start
- first day in weekmin
- minimal days of weekpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public JDateTime clone()
clone
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- JDateTime to comparepublic int compareTo(JDateTime jd)
public int compareDateTo(JDateTime jd)
public boolean isAfter(JDateTime then)
true
if current time is after then provided time.public boolean isBefore(JDateTime then)
true
if current time is before then provided time.public boolean isAfterDate(JDateTime then)
true
if current date is after then provided date.
Time component is ignored.public boolean isBeforeDate(JDateTime then)
true
if current date is before then provided date.
Time component is ignored.public int daysBetween(JDateTime then)
public int daysBetween(JulianDateStamp then)
public double getJulianDateDouble()
public JDateTime setJulianDate(double jd)
public boolean equalsDate(int year, int month, int day)
true
if provided date is equal to current one.
May be used for date validation test.public boolean equalsDate(JDateTime date)
true
if two dates are equal.
Time component is ignored.public boolean equalsTime(JDateTime date)
true
if two times are equal.
Date component is ignored.Copyright © 2003-present Jodd Team