@CalendarType(value="iso8601") public final class PlainTimestamp extends TimePoint<IsoUnit,PlainTimestamp> implements GregorianDate, WallTime, Temporal<PlainTimestamp>, ThreetenAdapter, Normalizer<IsoUnit>, LocalizedPatternSupport
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.HOUR_FROM_0_TO_24PlainTime.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.
|
static <S> Chronology<S> |
axis(Converter<S,PlainTimestamp> converter)
Provides a static access to the associated time axis using the foreign type S.
|
int |
compareTo(PlainTimestamp timestamp)
Defines the temporal order of date and time as natural order.
|
boolean |
equals(Object obj)
Compares the whole state of this instance with given object.
|
static <P extends ChronoPattern<P>> |
formatter(String formatPattern,
P patternType,
Locale locale)
Creates a new formatter which uses the given pattern and locale
for formatting and parsing plain timestamps.
|
static PlainTimestamp |
from(LocalDateTime ldt)
Short cut for
TemporalType.LOCAL_DATE_TIME.translate(ldt). |
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.
|
ZonalDateTime |
inLocalView()
Equivalent to
inZonalView(Timezone.ofSystem(). |
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.
|
ZonalDateTime |
inZonalView(Timezone tz)
Converts this instance to a combination of UTC-moment, given timezone and its zonal timestamp.
|
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(String formatPattern,
P patternType)
Creates a new formatter which uses the given pattern in the
default locale for formatting and parsing plain timestamps.
|
PlainTimestamp |
minus(long amount,
CalendarUnit unit)
Subtracts given amount in units from this timestamp and yields the result of subtraction.
|
PlainTimestamp |
minus(long amount,
ClockUnit unit)
Subtracts given amount in units from this timestamp and yields the result of subtraction.
|
Duration<IsoUnit> |
normalize(TimeSpan<? extends IsoUnit> timespan)
Normalized given timespan using years, months, days and
all clock units.
|
static PlainTimestamp |
nowInSystemTime()
Obtains the current timestamp in system time.
|
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.
|
PlainTimestamp |
plus(long amount,
CalendarUnit unit)
Adds given amount in units to this timestamp and yields the result of addition.
|
PlainTimestamp |
plus(long amount,
ClockUnit unit)
Adds given amount in units to this timestamp and yields the result of addition.
|
PlainDate |
toDate()
Synonym for
getCalendarDate(). |
String |
toString()
Creates a canonical representation of the form
"yyyy-MM-dd'T'HH:mm:ss,fffffffff".
|
LocalDateTime |
toTemporalAccessor()
Converts this object to a
TemporalAccessor. |
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, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withisAfterAll, isBeforeAllget, getLong, isSupported, query, rangepublic 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 static PlainTimestamp nowInSystemTime()
Obtains the current timestamp in system time.
Convenient short-cut for: SystemClock.inLocalView().now().
SystemClock.inLocalView(),
ZonalClock.now()public static PlainTimestamp from(LocalDateTime ldt)
Short cut for TemporalType.LOCAL_DATE_TIME.translate(ldt).
ldt - Threeten-equivalent of this instanceTemporalType.LOCAL_DATE_TIMEpublic 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 Comparable<PlainTimestamp>compareTo in class TimePoint<IsoUnit,PlainTimestamp>isBefore(PlainTimestamp),
isAfter(PlainTimestamp)public boolean equals(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 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(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 localeIllegalArgumentException - if resolving of pattern failspublic static <P extends ChronoPattern<P>> TemporalFormatter<PlainTimestamp> formatter(String formatPattern, P patternType, 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 localeIllegalArgumentException - if resolving of pattern failslocalFormatter(String,ChronoPattern)public LocalDateTime toTemporalAccessor()
ThreetenAdapterConverts this object to a TemporalAccessor.
Any implementation is required to return a new object with a different concrete type, not this instance.
toTemporalAccessor in interface ThreetenAdapterpublic static TimeAxis<IsoUnit,PlainTimestamp> axis()
Provides a static access to the associated time axis respective chronology which contains the chronological rules.
null)public static <S> Chronology<S> axis(Converter<S,PlainTimestamp> converter)
Provides a static access to the associated time axis using the foreign type S.
S - foreign temporal typeconverter - type converterTemporalType.LOCAL_DATE_TIMEpublic 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 idIllegalArgumentException - 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 ZonalDateTime inLocalView()
Equivalent to inZonalView(Timezone.ofSystem().
public ZonalDateTime inZonalView(Timezone tz)
Converts this instance to a combination of UTC-moment, given timezone and its zonal timestamp.
Attention: Due to winter/summer-time-changes the resulting zonal timestamp
(ZonalDateTime.toTimestamp()) can deviate from this plain timestamp.
tz - timezonepublic boolean isValid(TZID tzid)
Does this local timestamp exist in given timezone?
tzid - timezone id (optional)true if this timestamp is valid in given timezoneIllegalArgumentException - 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)public PlainTimestamp plus(long amount, CalendarUnit unit)
Adds given amount in units to this timestamp and yields the result of addition.
Covers the most important calendar units and is overloaded for performance reasons.
amount - the amount of units to be added to this timestamp (maybe negative)unit - the unit to be used in additionArithmeticException - in case of numerical overflowplus(long, IsoUnit)public PlainTimestamp plus(long amount, ClockUnit unit)
Adds given amount in units to this timestamp and yields the result of addition.
Covers the most important clock units and is overloaded for performance reasons.
amount - the amount of units to be added to this timestamp (maybe negative)unit - the unit to be used in additionArithmeticException - in case of numerical overflowplus(long, IsoUnit)public PlainTimestamp minus(long amount, CalendarUnit unit)
Subtracts given amount in units from this timestamp and yields the result of subtraction.
Covers the most important calendar units and is overloaded for performance reasons.
amount - the amount of units to be subtracted from this timestamp (maybe negative)unit - the unit to be used in subtractionArithmeticException - in case of numerical overflowminus(long, IsoUnit)public PlainTimestamp minus(long amount, ClockUnit unit)
Subtracts given amount in units from this timestamp and yields the result of subtraction.
Covers the most important clock units and is overloaded for performance reasons.
amount - the amount of units to be subtracted from this timestamp (maybe negative)unit - the unit to be used in subtractionArithmeticException - in case of numerical overflowminus(long, IsoUnit)Copyright © 2014–2017. All rights reserved.