MCPcopy Create free account
hub / github.com/amazon-ion/ion-java / make_localtime

Method make_localtime

src/main/java/com/amazon/ion/Timestamp.java:1236–1265  ·  view source on GitHub ↗

Applies the local offset from UTC to each of the applicable time field values and returns the new Timestamp. In short, this makes the Timestamp represent local time. @return a new Timestamp in its local time

()

Source from the content-addressed store, hash-verified

1234 * @return a new Timestamp in its local time
1235 */
1236 private Timestamp make_localtime()
1237 {
1238 int offset = _offset != null
1239 ? _offset.intValue()
1240 : 0;
1241
1242 // We use a Copy-Constructor that expects the time parameters to be in
1243 // UTC, as that's what we're supposed to have.
1244 // As this Copy-Constructor doesn't apply local offset to the time
1245 // field values (it assumes that the local offset is already applied to
1246 // them), we explicitly apply the local offset to the time field values
1247 // after we obtain the new Timestamp instance.
1248 Timestamp localtime = new Timestamp(_precision,
1249 _year,
1250 _month,
1251 _day,
1252 _hour,
1253 _minute,
1254 _second,
1255 _fraction,
1256 _offset,
1257 APPLY_OFFSET_NO,
1258 CHECK_FRACTION_NO);
1259 // explicitly apply the local offset to the time field values
1260 localtime.apply_offset(-offset);
1261
1262 assert localtime._offset == _offset;
1263
1264 return localtime;
1265 }
1266
1267 /**
1268 * Returns a Timestamp, precise to the year, with unknown local offset.

Callers 7

getYearMethod · 0.95
getMonthMethod · 0.95
getDayMethod · 0.95
getHourMethod · 0.95
getMinuteMethod · 0.95
printMethod · 0.95
addMillisForPrecisionMethod · 0.95

Calls 2

apply_offsetMethod · 0.95
intValueMethod · 0.65

Tested by

no test coverage detected