@CalendarType(value="iso8601") public final class PlainTimestamp extends TimePoint<IsoUnit,PlainTimestamp> implements GregorianDate, WallTime, Temporal<PlainTimestamp>, Normalizer<IsoUnit>
Represents a plain composition of calendar date and wall time as defined in ISO-8601, but without any timezone.
Following elements which are declared as constants are registered by this class:
PlainDate.COMPONENTPlainDate.YEARPlainDate.YEAR_OF_WEEKDATEPlainDate.QUARTER_OF_YEARPlainDate.MONTH_OF_YEARPlainDate.MONTH_AS_NUMBERPlainDate.DAY_OF_MONTHPlainDate.DAY_OF_QUARTERPlainDate.DAY_OF_WEEKPlainDate.DAY_OF_YEARPlainDate.WEEKDAY_IN_MONTHPlainTime.COMPONENTPlainTime.AM_PM_OF_DAYPlainTime.CLOCK_HOUR_OF_AMPMPlainTime.CLOCK_HOUR_OF_DAYPlainTime.DIGITAL_HOUR_OF_AMPMPlainTime.DIGITAL_HOUR_OF_DAYPlainTime.ISO_HOURPlainTime.MINUTE_OF_HOURPlainTime.MINUTE_OF_DAYPlainTime.SECOND_OF_MINUTEPlainTime.SECOND_OF_DAYPlainTime.MILLI_OF_SECONDPlainTime.MICRO_OF_SECONDPlainTime.NANO_OF_SECONDPlainTime.MILLI_OF_DAYPlainTime.MICRO_OF_DAYPlainTime.NANO_OF_DAYPlainTime.DECIMAL_HOURPlainTime.DECIMAL_MINUTEPlainTime.DECIMAL_SECONDPlainTime.PRECISIONFurthermore, all elements of class Weekmodel are supported. As
timestamp units can be used: CalendarUnit and ClockUnit.
Note: The special time value 24:00 is only supported in the factory methods which normalize the resulting timestamp to midnight of the following day. In element access and manipulations this value is not supported.
| Modifier and Type | Method and Description |
|---|---|
Moment |
at(ZonalOffset offset)
Combines this local timestamp with the given timezone offset
to a global UTC-moment.
|
Moment |
atUTC()
Combines this local timestamp with the timezone offset UTC+00:00
to a global UTC-moment.
|
static TimeAxis<IsoUnit,PlainTimestamp> |
axis()
Provides a static access to the associated time axis respective
chronology which contains the chronological rules.
|
int |
compareTo(PlainTimestamp timestamp)
Defines the temporal order of date and time as natural order.
|
boolean |
equals(java.lang.Object obj)
Compares the whole state of this instance with given object.
|
static <P extends ChronoPattern<P>> |
formatter(java.lang.String formatPattern,
P patternType,
java.util.Locale locale)
Creates a new formatter which uses the given pattern and locale
for formatting and parsing plain timestamps.
|
PlainDate |
getCalendarDate()
Provides the calendar date part.
|
int |
getDayOfMonth()
Yields the day of month.
|
int |
getHour()
Yields the hour of day.
|
int |
getMinute()
Liefert die Minute (der aktuellen Stunde).
|
int |
getMonth()
Yields the gregorian month as integer.
|
int |
getNanosecond()
Yields the nanosecond.
|
int |
getSecond()
Yields the second of minute.
|
PlainTime |
getWallTime()
Provides the wall time part.
|
int |
getYear()
Yields the proleptic year according to ISO-8601.
|
int |
hashCode()
Subclasses must redefine this method corresponding to the
behaviour of
equals(). |
Moment |
in(Timezone tz)
Combines this local timestamp with given timezone to a global
UTC-moment.
|
Moment |
inStdTimezone()
Combines this local timestamp with the system timezone to a global
UTC-moment.
|
Moment |
inTimezone(TZID tzid)
Combines this local timestamp with given timezone to a global
UTC-moment.
|
boolean |
isAfter(PlainTimestamp timestamp)
Queries if this object is after given object on a timeline.
|
boolean |
isBefore(PlainTimestamp timestamp)
Queries if this object is before given object on a timeline.
|
boolean |
isSimultaneous(PlainTimestamp timestamp)
Queries if this object and given object have the same position
on the time axis.
|
boolean |
isValid(TZID tzid)
Does this local timestamp exist in given timezone?
|
static <P extends ChronoPattern<P>> |
localFormatter(java.lang.String formatPattern,
P patternType)
Creates a new formatter which uses the given pattern in the
default locale for formatting and parsing plain timestamps.
|
Duration<IsoUnit> |
normalize(TimeSpan<? extends IsoUnit> timespan)
Normalized given timespan using years, months, days and
all clock units.
|
static PlainTimestamp |
of(int year,
int month,
int dayOfMonth,
int hour,
int minute)
Creates a new local timestamp in minute precision.
|
static PlainTimestamp |
of(int year,
int month,
int dayOfMonth,
int hour,
int minute,
int second)
Creates a new local timestamp in second precision.
|
static PlainTimestamp |
of(PlainDate date,
PlainTime time)
Creates a new local timestamp with calendar date and wall time.
|
PlainDate |
toDate()
Synonym for
getCalendarDate(). |
java.lang.String |
toString()
Creates a canonical representation of the form
"yyyy-MM-dd'T'HH:mm:ss,fffffffff".
|
PlainTime |
toTime()
Synonym for
getWallTime(). |
PlainTimestamp |
with(ElementOperator<?> operator)
Adjusts this timestamp by given operator.
|
PlainTimestamp |
with(PlainDate date)
Adjusts the calendar part of this timestamp.
|
PlainTimestamp |
with(PlainTime time)
Adjusts the wall time part of this timestamp.
|
max, min, minus, minus, plus, plus, until, untilcontains, get, get, getMaximum, getMinimum, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withpublic static PlainTimestamp of(PlainDate date, PlainTime time)
Creates a new local timestamp with calendar date and wall time.
The special time value 24:00 will automatically normalized such that the resulting timestamp is on starting midnight of following day.
date - calendar date componenttime - wall time component (24:00 will always be normalized)of(int, int, int, int, int),
of(int, int, int, int, int, int)public static PlainTimestamp of(int year, int month, int dayOfMonth, int hour, int minute)
Creates a new local timestamp in minute precision.
The special time value 24:00 will automatically normalized such that the resulting timestamp is on starting midnight of following day.
year - proleptic iso year [(-999,999,999)-999,999,999]month - gregorian month in range (1-12)dayOfMonth - day of month in range (1-31)hour - hour in the range 0-23 or 24
if minute and second are equal to 0minute - minute in the range 0-59public static PlainTimestamp of(int year, int month, int dayOfMonth, int hour, int minute, int second)
Creates a new local timestamp in second precision.
The special time value 24:00 will automatically normalized such that the resulting timestamp is on starting midnight of following day.
year - proleptic iso year [(-999,999,999)-999,999,999]month - gregorian month in range (1-12)dayOfMonth - day of month in range (1-31)hour - hour in the range 0-23 or 24
if minute and second are equal to 0minute - minute in the range 0-59second - second in the range 0-59public PlainDate getCalendarDate()
Provides the calendar date part.
public PlainTime getWallTime()
Provides the wall time part.
public int getYear()
GregorianDateYields the proleptic year according to ISO-8601.
The term proleptic means that the gregorian calendar rules are applied backwards even before the introduction of this calendar. Second: The year numbering is just the mathematical one as defined in ISO-8601 such that there is a year zero and even negative years: -2 = BC 3, -1 = BC 2, 0 = BC 1, 1 = AD 1, 2 = AD 2, ...
getYear in interface GregorianDateGregorianMath.MIN_YEAR - GregorianMath.MAX_YEARpublic int getMonth()
GregorianDateYields the gregorian month as integer.
getMonth in interface GregorianDatepublic int getDayOfMonth()
GregorianDateYields the day of month.
getDayOfMonth in interface GregorianDate1 <= dayOfMonth <= 31public int getHour()
WallTimeYields the hour of day.
public int getMinute()
WallTimeLiefert die Minute (der aktuellen Stunde).
public int getSecond()
WallTimeYields the second of minute.
Given this context and the fact that this interface describes
an analogue clock without UTC reference, the special leapsecond
value 60 cannot be supported.
public int getNanosecond()
WallTimeYields the nanosecond.
Implementations which are not capable of nanosecond precision
will just yield 0 or another suitable rounded value.
getNanosecond in interface WallTime0 - 999,999,999public PlainTimestamp with(ElementOperator<?> operator)
Adjusts this timestamp by given operator.
operator - element-related operatorChronoEntity.with(net.time4j.engine.ChronoOperator)public PlainTimestamp with(PlainDate date)
Adjusts the calendar part of this timestamp.
date - new calendar date componentPlainDate.COMPONENTpublic PlainTimestamp with(PlainTime time)
Adjusts the wall time part of this timestamp.
time - new wall time componentPlainTime.COMPONENTpublic boolean isBefore(PlainTimestamp timestamp)
TemporalQueries if this object is before given object on a timeline.
isBefore in interface Temporal<PlainTimestamp>timestamp - object this instance is compared totrue if this instance is temporally before
temporal else falsepublic boolean isAfter(PlainTimestamp timestamp)
TemporalQueries if this object is after given object on a timeline.
isAfter in interface Temporal<PlainTimestamp>timestamp - object this instance is compared totrue if this instance is temporally after
temporal else falsepublic boolean isSimultaneous(PlainTimestamp timestamp)
TemporalQueries if this object and given object have the same position on the time axis.
Is equivalent to !isAfter(temporal) && !isBefore(temporal).
This method differs from the Object-method equals()
such that first the comparison type must be a temporal one and second
that only temporal-only state will be considered.
isSimultaneous in interface Temporal<PlainTimestamp>timestamp - object this instance is compared totrue if this instance is temporally equal
to temporal else falsepublic int compareTo(PlainTimestamp timestamp)
Defines the temporal order of date and time as natural order.
The comparison is consistent with equals().
compareTo in interface java.lang.Comparable<PlainTimestamp>compareTo in class TimePoint<IsoUnit,PlainTimestamp>isBefore(PlainTimestamp),
isAfter(PlainTimestamp)public boolean equals(java.lang.Object obj)
TimePointCompares the whole state of this instance with given object.
Implementations will usually define their state only based on the temporal position on the time axis because this is the most intuitive approach. Exceptions from this rule should be explicitly documented and reasoned.
equals in class TimePoint<IsoUnit,PlainTimestamp>TimePoint.compareTo(TimePoint)public int hashCode()
TimePointSubclasses must redefine this method corresponding to the
behaviour of equals().
hashCode in class TimePoint<IsoUnit,PlainTimestamp>public java.lang.String toString()
Creates a canonical representation of the form "yyyy-MM-dd'T'HH:mm:ss,fffffffff".
Dependent on the precision (that is last non-zero part of time) the time representation might be shorter.
toString in interface GregorianDatetoString in interface WallTimetoString in class TimePoint<IsoUnit,PlainTimestamp>PlainTime.toString()public PlainDate toDate()
Synonym for getCalendarDate().
getCalendarDate()public PlainTime toTime()
Synonym for getWallTime().
getWallTime()public static <P extends ChronoPattern<P>> TemporalFormatter<PlainTimestamp> localFormatter(java.lang.String formatPattern, P patternType)
Creates a new formatter which uses the given pattern in the default locale for formatting and parsing plain timestamps.
P - generic pattern typeformatPattern - format definition as patternpatternType - pattern dialectPlainTimestamp-objects
using system localejava.lang.IllegalArgumentException - if resolving of pattern failspublic static <P extends ChronoPattern<P>> TemporalFormatter<PlainTimestamp> formatter(java.lang.String formatPattern, P patternType, java.util.Locale locale)
Creates a new formatter which uses the given pattern and locale for formatting and parsing plain timestamps.
P - generic pattern typeformatPattern - format definition as patternpatternType - pattern dialectlocale - locale settingPlainTimestamp-objects using given localejava.lang.IllegalArgumentException - if resolving of pattern failslocalFormatter(String,ChronoPattern)public static TimeAxis<IsoUnit,PlainTimestamp> axis()
Provides a static access to the associated time axis respective chronology which contains the chronological rules.
null)public Moment atUTC()
Combines this local timestamp with the timezone offset UTC+00:00 to a global UTC-moment.
at(ZonalOffset)public Moment at(ZonalOffset offset)
Combines this local timestamp with the given timezone offset to a global UTC-moment.
offset - timezone offsetatUTC(),
in(Timezone)public Moment inStdTimezone()
Combines this local timestamp with the system timezone to a global UTC-moment.
Timezone.ofSystem(),
inTimezone(TZID)public Moment inTimezone(TZID tzid)
Combines this local timestamp with given timezone to a global UTC-moment.
tzid - timezone idjava.lang.IllegalArgumentException - if given timezone cannot be loadedTimezone.of(TZID),
inStdTimezone()public Moment in(Timezone tz)
Combines this local timestamp with given timezone to a global UTC-moment.
tz - timezoneTimezone.of(String)public boolean isValid(TZID tzid)
Does this local timestamp exist in given timezone?
tzid - timezone id (optional)true if this timestamp is valid in given timezonejava.lang.IllegalArgumentException - if given timezone cannot be loadedpublic Duration<IsoUnit> normalize(TimeSpan<? extends IsoUnit> timespan)
Normalized given timespan using years, months, days and all clock units.
This normalizer can also convert from days to months. Example:
Duration<CalendarUnit> dur = Duration.of(30, CalendarUnit.DAYS);
Duration<IsoUnit> result =
PlainTimestamp.of(2012, 2, 28, 0, 0).normalize(dur);
System.out.println(result); // output: P1M1D (leap year!)
normalize in interface Normalizer<IsoUnit>timespan - to be normalizedDuration.with(Normalizer)