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

Method readHour

base/src/main/java/net/time4j/PlainTime.java:3493–3533  ·  view source on GitHub ↗
(ChronoEntity<?> entity)

Source from the content-addressed store, hash-verified

3491
3492 // read to digital hour 0-23 (or -1 / -2 in case of zero clock hour)
3493 private static int readHour(ChronoEntity<?> entity) {
3494
3495 int hour = entity.getInt(DIGITAL_HOUR_OF_DAY);
3496
3497 if (hour != Integer.MIN_VALUE) {
3498 return hour;
3499 }
3500
3501 hour = entity.getInt(CLOCK_HOUR_OF_DAY);
3502
3503 if (hour == 0) {
3504 return -1; // flag for wrong zero clock hour
3505 } else if (hour == 24) {
3506 return 0;
3507 } else if (hour != Integer.MIN_VALUE) {
3508 return hour;
3509 }
3510
3511 if (entity.contains(AM_PM_OF_DAY)) {
3512 Meridiem ampm = entity.get(AM_PM_OF_DAY);
3513 int h = entity.getInt(CLOCK_HOUR_OF_AMPM);
3514
3515 if (h != Integer.MIN_VALUE) {
3516 if (h == 0) {
3517 return ((ampm == Meridiem.AM) ? -1 : -2); // flag for wrong zero clock hour
3518 } else if (h == 12) {
3519 h = 0;
3520 }
3521 return ((ampm == Meridiem.AM) ? h : h + 12);
3522 }
3523
3524 h = entity.getInt(DIGITAL_HOUR_OF_AMPM);
3525
3526 if (h != Integer.MIN_VALUE) {
3527 return ((ampm == Meridiem.AM) ? h : h + 12);
3528 }
3529 }
3530
3531 return Integer.MIN_VALUE;
3532
3533 }
3534
3535 private static PlainTime readSpecialCases(ChronoEntity<?> entity) {
3536

Callers 1

createFromMethod · 0.95

Calls 3

getIntMethod · 0.65
containsMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected