MCPcopy Create free account
hub / github.com/MenoData/Time4J / at

Method at

base/src/main/java/net/time4j/GeneralTimestamp.java:384–406  ·  view source on GitHub ↗
(
        ZonalOffset offset,
        StartOfDay startOfDay
    )

Source from the content-addressed store, hash-verified

382 * @since 3.8/4.5
383 */
384 public Moment at(
385 ZonalOffset offset,
386 StartOfDay startOfDay
387 ) {
388
389 PlainTimestamp tsp = (
390 (this.cv == null)
391 ? this.ca.transform(PlainDate.class).at(this.time)
392 : this.cv.transform(PlainDate.class).at(this.time));
393
394 // assuming that deviation will not change much by one day difference (approximation)
395 int deviation = startOfDay.getDeviation(tsp.getCalendarDate(), offset);
396 int comp = this.time.get(PlainTime.SECOND_OF_DAY).intValue() - deviation;
397
398 if (comp >= 86400) { // happens if sunset is the start of day
399 tsp = tsp.minus(1, CalendarUnit.DAYS);
400 } else if (comp < 0) { // happens if sunrise is the start of day
401 tsp = tsp.plus(1, CalendarUnit.DAYS);
402 }
403
404 return tsp.at(offset);
405
406 }
407
408 /**
409 * <p>Combines this general timestamp with given timezone to a global UTC-moment. </p>

Callers

nothing calls this directly

Calls 8

getCalendarDateMethod · 0.95
minusMethod · 0.95
plusMethod · 0.95
atMethod · 0.95
atMethod · 0.65
transformMethod · 0.65
getMethod · 0.65
getDeviationMethod · 0.45

Tested by

no test coverage detected