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

Method at

base/src/main/java/net/time4j/PlainTimestamp.java:1002–1026  ·  view source on GitHub ↗
(ZonalOffset offset)

Source from the content-addressed store, hash-verified

1000 * @see #in(Timezone)
1001 */
1002 public Moment at(ZonalOffset offset) {
1003
1004 long localSeconds =
1005 MathUtils.safeMultiply(
1006 this.date.getDaysSinceUTC() + 2 * 365,
1007 86400);
1008 localSeconds += (this.time.getHour() * 3600);
1009 localSeconds += (this.time.getMinute() * 60);
1010 localSeconds += this.time.getSecond();
1011
1012 int localNanos = this.time.getNanosecond();
1013 long posixTime = localSeconds - offset.getIntegralAmount();
1014 int posixNanos = localNanos - offset.getFractionalAmount();
1015
1016 if (posixNanos < 0) {
1017 posixNanos += MRD;
1018 posixTime--;
1019 } else if (posixNanos >= MRD) {
1020 posixNanos -= MRD;
1021 posixTime++;
1022 }
1023
1024 return Moment.of(posixTime, posixNanos, TimeScale.POSIX);
1025
1026 }
1027
1028 /**
1029 * <p>Combines this local timestamp with the system timezone to a global

Callers 7

equationOfTimeRoundedMethod · 0.95
atUTCMethod · 0.95
inMethod · 0.95
atMethod · 0.95
nextIntervalMethod · 0.95
getTransitionTimeMethod · 0.95
translateMethod · 0.95

Calls 9

safeMultiplyMethod · 0.95
ofMethod · 0.95
getDaysSinceUTCMethod · 0.80
getHourMethod · 0.65
getMinuteMethod · 0.65
getSecondMethod · 0.65
getNanosecondMethod · 0.65
getIntegralAmountMethod · 0.45
getFractionalAmountMethod · 0.45

Tested by 1

equationOfTimeRoundedMethod · 0.76