java.lang.Object | |
↳ | org.joda.time.DateTimeUtils |
DateTimeUtils provide public utility methods for the date-time library.
DateTimeUtils is thread-safe although shared static variables are used.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Restrictive constructor
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the current time in milliseconds.
| |||||||||||
Gets the chronology handling null.
| |||||||||||
Gets the millisecond duration from the specified duration object handling null.
| |||||||||||
Gets the chronology from the specified instant object handling null.
| |||||||||||
Gets the millisecond instant from the specified instant object handling null.
| |||||||||||
Gets the chronology from the specified instant based interval handling null.
| |||||||||||
Gets the chronology from the specified interval object handling null.
| |||||||||||
Gets the period type handling null.
| |||||||||||
Gets the interval handling null.
| |||||||||||
Gets the zone handling null.
| |||||||||||
Checks whether the partial is contiguous.
| |||||||||||
Sets the current time to return a fixed millisecond time.
| |||||||||||
Sets the current time to return the system time plus an offset.
| |||||||||||
Resets the current time to return the system time.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Restrictive constructor
Gets the current time in milliseconds.
By default this returns System.currentTimeMillis()
.
This may be changed using other methods in this class.
Gets the chronology handling null.
If the chronology is null
, getInstance()
will be returned. Otherwise, the chronology is returned.
chrono | the chronology to use, null means ISO in the default zone |
---|
Gets the millisecond duration from the specified duration object handling null.
If the duration object is null
, zero will be returned.
Otherwise, the millis from the object are returned.
duration | the duration to examine, null means zero |
---|
Gets the chronology from the specified instant object handling null.
If the instant object is null
, or the instant's chronology is
null
, getInstance()
will be returned.
Otherwise, the chronology from the object is returned.
instant | the instant to examine, null means ISO in the default zone |
---|
Gets the millisecond instant from the specified instant object handling null.
If the instant object is null
, the currentTimeMillis()
will be returned. Otherwise, the millis from the object are returned.
instant | the instant to examine, null means now |
---|
Gets the chronology from the specified instant based interval handling null.
The chronology is obtained from the start if that is not null, or from the
end if the start is null. The result is additionally checked, and if still
null then getInstance()
will be returned.
start | the instant to examine and use as the primary source of the chronology |
---|---|
end | the instant to examine and use as the secondary source of the chronology |
Gets the chronology from the specified interval object handling null.
If the interval object is null
, or the interval's chronology is
null
, getInstance()
will be returned.
Otherwise, the chronology from the object is returned.
interval | the interval to examine, null means ISO in the default zone |
---|
Gets the period type handling null.
If the zone is null
, standard()
will be returned. Otherwise, the type specified is returned.
type | the time zone to use, null means the standard type |
---|
Gets the interval handling null.
If the interval is null
, an interval representing now
to now in the ISOChronology
will be returned. Otherwise, the interval specified is returned.
interval | the interval to use, null means now to now |
---|
Gets the zone handling null.
If the zone is null
, getDefault()
will be returned. Otherwise, the zone specified is returned.
zone | the time zone to use, null means the default zone |
---|
Checks whether the partial is contiguous.
A partial is contiguous if one field starts where another ends.
For example LocalDate
is contiguous because DayOfMonth has
the same range (Month) as the unit of the next field (MonthOfYear), and
MonthOfYear has the same range (Year) as the unit of the next field (Year).
Similarly, LocalTime
is contiguous, as it consists of
MillisOfSecond, SecondOfMinute, MinuteOfHour and HourOfDay (note how
the names of each field 'join up').
However, a Year/HourOfDay partial is not contiguous because the range field Day is not equal to the next field Year. Similarly, a DayOfWeek/DayOfMonth partial is not contiguous because the range Month is not equal to the next field Day.
partial | the partial to check |
---|
IllegalArgumentException | if the partial is null |
---|
Sets the current time to return a fixed millisecond time.
This method changes the behaviour of currentTimeMillis()
.
Whenever the current time is queried, the same millisecond time will be returned.
fixedMillis | the fixed millisecond time to use |
---|
SecurityException | if the application does not have sufficient security rights |
---|
Sets the current time to return the system time plus an offset.
This method changes the behaviour of currentTimeMillis()
.
Whenever the current time is queried, currentTimeMillis()
is used
and then offset by adding the millisecond value specified here.
offsetMillis | the fixed millisecond time to use |
---|
SecurityException | if the application does not have sufficient security rights |
---|
Resets the current time to return the system time.
This method changes the behaviour of currentTimeMillis()
.
Whenever the current time is queried, currentTimeMillis()
is used.
SecurityException | if the application does not have sufficient security rights |
---|