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

Method getValue

base/src/main/java/net/time4j/Moment.java:3264–3291  ·  view source on GitHub ↗
(Moment context)

Source from the content-addressed store, hash-verified

3262 //~ Methoden ------------------------------------------------------
3263
3264 @Override
3265 public TimeUnit getValue(Moment context) {
3266
3267 int f = context.getNanosecond();
3268
3269 if (f != 0) {
3270 if ((f % MIO) == 0) {
3271 return TimeUnit.MILLISECONDS;
3272 } else if ((f % 1000) == 0) {
3273 return TimeUnit.MICROSECONDS;
3274 } else {
3275 return TimeUnit.NANOSECONDS;
3276 }
3277 }
3278
3279 long secs = context.posixTime;
3280
3281 if (Math.floorMod(secs, 86400) == 0) {
3282 return TimeUnit.DAYS;
3283 } else if (Math.floorMod(secs, 3600) == 0) {
3284 return TimeUnit.HOURS;
3285 } else if (Math.floorMod(secs, 60) == 0) {
3286 return TimeUnit.MINUTES;
3287 } else {
3288 return TimeUnit.SECONDS;
3289 }
3290
3291 }
3292
3293 @Override
3294 public Moment withValue(

Callers

nothing calls this directly

Calls 2

floorModMethod · 0.80
getNanosecondMethod · 0.65

Tested by

no test coverage detected