@Override protected MomentInterval nextInterval() { PlainTimestamp next; Boundary<Moment> s; Boundary<Moment> e; if (RecurrentMomentIntervals.this.isBackwards()) { next = this.current.minus(RecurrentMomentIntervals.this.duration); s = Boundary.ofClosed(next.at(offset)); e = Boundary.ofOpen(this.current.at(offset)); } else { next = this.current.plus(RecurrentMomentIntervals.this.duration); s = Boundary.ofClosed(this.current.at(offset)); e = Boundary.ofOpen(next.at(offset)); } this.current = next; return MomentIntervalFactory.INSTANCE.between(s, e); } };
ChronoInterval<PlainTimestamp> missed0 = missed.get(0); PlainTimestamp tsp = missed0.getStart().getTemporal(); LocalDateTime ldt = // joda-equivalent new LocalDateTime( tsp.getYear(), tsp.getMonth(), tsp.getDayOfMonth(), tsp.getHour(), tsp.getMinute(), tsp.getSecond(), tsp.get(PlainTime.MILLI_OF_SECOND)); System.out.println(ldt); // 2016-01-01T10:00:00.000
@Override public <V> V getMaximum(ChronoElement<V> element) { V max; if (this.timestamp.contains(element)) { max = this.timestamp.getMaximum(element); } else { max = this.moment.getMaximum(element); } if ( (element == SECOND_OF_MINUTE) && (this.timestamp.getYear() >= 1972) ) { PlainTimestamp ts = this.timestamp.with(element, max); if (!this.zone.isInvalid(ts, ts)) { Moment transformed = ts.in(this.zone); Moment test = transformed.plus(1, SI.SECONDS); if (test.isLeapSecond()) { return element.getType().cast(Integer.valueOf(60)); } } } return max; }
@Override public LocalDateTime from(PlainTimestamp tsp) { return LocalDateTime.of( tsp.getYear(), tsp.getMonth(), tsp.getDayOfMonth(), tsp.getHour(), tsp.getMinute(), tsp.getSecond(), tsp.getNanosecond() ); }
private CalendarOperator(int type) { super(PlainDate.COMPONENT, type); this.tsop = entity -> { PlainDate date = doApply(entity.getCalendarDate()); return entity.with(date); }; }
sb.append(this.timestamp.getCalendarDate()); sb.append('T'); int hour = this.timestamp.getHour(); if (hour < 10) { sb.append('0'); int minute = this.timestamp.getMinute(); if (minute < 10) { sb.append('0'); sb.append("60"); } else { int second = this.timestamp.getSecond(); if (second < 10) { sb.append('0'); int n = this.timestamp.getNanosecond(); if (n != 0) { PlainTime.printNanos(sb, n);
int deviation = startOfDay.getDeviation(tsp.getCalendarDate(), offset); int comp = this.time.get(PlainTime.SECOND_OF_DAY).intValue() - deviation; tsp = tsp.minus(1, CalendarUnit.DAYS); } else if (comp < 0) { // happens if sunrise is the start of day tsp = tsp.plus(1, CalendarUnit.DAYS); return tsp.at(offset);
int deviation = startOfDay.getDeviation(tsp.getCalendarDate(), tz.getID()); int comp = this.time.get(PlainTime.SECOND_OF_DAY).intValue() - deviation; tsp = tsp.minus(1, CalendarUnit.DAYS); } else if (comp < 0) { // happens if sunrise is the start of day tsp = tsp.plus(1, CalendarUnit.DAYS); return tsp.in(tz);
private FullValueOperator(int type) { super(PlainTime.COMPONENT, type); this.tsop = entity -> { PlainTime time = doApply(entity.getWallTime()); if (time.getHour() == 24) { return PlainTimestamp.of( entity.getCalendarDate().plus(1, DAYS), PlainTime.midnightAtStartOfDay()); } else { return entity.with(time); } }; }
PlainTime time = tsp.getWallTime(); int deviation = startOfDay.getDeviation(tsp.getCalendarDate(), tzid); tsp = tsp.minus(deviation, ClockUnit.SECONDS); C date = tsp.getCalendarDate().transform(chronology.getChronoType()); return GeneralTimestamp.of(date, time);
PlainTimestamp tsp = PlainTimestamp.axis().createFrom(threeten, attributes); if (attributes.contains(Attributes.TRANSITION_STRATEGY)) { TransitionStrategy strategy = attributes.get(Attributes.TRANSITION_STRATEGY); return tsp.in(Timezone.of(tzid).with(strategy)); } else { return tsp.inTimezone(tzid);
Date jud = sdf.parse(parseable, position); PlainTimestamp tsp = TemporalType.JAVA_UTIL_DATE.translate(jud).toZonalTimestamp(ZonalOffset.UTC); result = tsp.getCalendarDate(); updateRawValues(rawValues, sdf); } else if (this.type.equals(PlainTime.class)) { Date jud = sdf.parse(parseable, position); PlainTimestamp tsp = TemporalType.JAVA_UTIL_DATE.translate(jud).toZonalTimestamp(ZonalOffset.UTC); result = tsp.getWallTime(); updateRawValues(rawValues, sdf); } else if (this.type.equals(PlainTimestamp.class)) { parsed.setTimezone(parsedTimezone); PlainTimestamp tsp = PlainTimestamp.axis().createFrom(parsed, this.getAttributes(), this.leniency.isLax(), false); if (tsp == null) { result = null; } else { result = tsp.inTimezone(parsedTimezone).inZonalView(parsedTimezone);
import static net.time4j.tz.GapResolver.NEXT_VALID_TIME; import static net.time4j.tz.OverlapResolver.EARLIER_OFFSET; PlainTimestamp tsp = PlainTimestamp.of(2015, 3, 29, 2, 30); Moment nextValidTime = // equivalent of java.time.Instant tsp.in(Timezone.of(EUROPE.BERLIN).with(NEXT_VALID_TIME.and(EARLIER_OFFSET))); tsp = nextValidTime.toZonalTimestamp(EUROPE.BERLIN); System.out.println(tsp); // 2015-03-29T03 (minute is zero and therefore left out here)
/** * <p>Combines this local timestamp with the timezone offset UTC+00:00 * to a global UTC-moment. </p> * * @return global UTC-moment based on this local timestamp interpreted * at offset UTC+00:00 * @see #at(ZonalOffset) */ /*[deutsch] * <p>Kombiniert diesen lokalen Zeitstempel mit UTC+00:00 zu * einem globalen UTC-Moment. </p> * * @return global UTC-moment based on this local timestamp interpreted * at offset UTC+00:00 * @see #at(ZonalOffset) */ public Moment atUTC() { return this.at(ZonalOffset.UTC); }
buffer.append(infinityStyle.displayPast(printer, PlainTimestamp.axis())); } else { Iso8601Format.ofDate(dateStyle).print(start.getCalendarDate(), buffer); buffer.append('T'); timePrinter.print(start.getWallTime(), buffer); PlainDate d1 = start.getCalendarDate(); PlainDate d2 = end.getCalendarDate(); if (!d1.equals(d2)) { DateInterval.getEndPrinter(dateStyle, d1, d2).print(d2, buffer); timePrinter.print(end.getWallTime(), buffer); } else if (interval.getEnd().isInfinite()) { if (printer == null) { printer = Iso8601Format.ofTimestamp(dateStyle, decimalStyle, precision); buffer.append(infinityStyle.displayFuture(printer, PlainTimestamp.axis())); } else { if (printer == null) {
/** * <p>Creates a finite half-open interval between given time points. </p> * * @param start timestamp of lower boundary (inclusive) * @param end timestamp of upper boundary (exclusive) * @return new timestamp interval * @throws IllegalArgumentException if start is after end * @see #between(PlainTimestamp, PlainTimestamp) * @since 4.11 */ /*[deutsch] * <p>Erzeugt ein begrenztes halb-offenes Intervall zwischen den * angegebenen Zeitpunkten. </p> * * @param start timestamp of lower boundary (inclusive) * @param end timestamp of upper boundary (exclusive) * @return new timestamp interval * @throws IllegalArgumentException if start is after end * @see #between(PlainTimestamp, PlainTimestamp) * @since 4.11 */ public static TimestampInterval between( LocalDateTime start, LocalDateTime end ) { return TimestampInterval.between(PlainTimestamp.from(start), PlainTimestamp.from(end)); }
@Override public Chronology<?> preparser() { return PlainTimestamp.axis(); }
private void writeTimestamp(DataOutput out) throws IOException { PlainTimestamp ts = (PlainTimestamp) this.obj; writeDate(ts.getCalendarDate(), TIMESTAMP_TYPE, out); writeTime(ts.getWallTime(), out); }
@Override public Moment plusPeriod( Moment timepoint, String period, ParseLog plog, AttributeQuery attributes ) { Timezone tz = getTimezone(plog.getRawValues(), attributes); PlainTimestamp tsp = timepoint.toZonalTimestamp(tz.getID()); try { return tsp.plus(Duration.parsePeriod(period)).in(tz); } catch (ParseException ex) { return null; } }
@Override public Moment minusPeriod( Moment timepoint, String period, ParseLog plog, AttributeQuery attributes ) { Timezone tz = getTimezone(plog.getRawValues(), attributes); PlainTimestamp tsp = timepoint.toZonalTimestamp(tz.getID()); try { return tsp.minus(Duration.parsePeriod(period)).in(tz); } catch (ParseException ex) { return null; } }