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

Class Normalized

base/src/main/java/net/time4j/MachineTime.java:1671–1775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1669 }
1670
1671 private static class Normalized
1672 implements TimeSpan<TimeUnit> {
1673
1674 //~ Instanzvariablen ----------------------------------------------
1675
1676 private final TimeSpan<? super TimeUnit> duration;
1677 private final Set<TimeUnit> patternUnits;
1678
1679 //~ Konstruktoren -------------------------------------------------
1680
1681 Normalized(
1682 TimeSpan<? super TimeUnit> duration,
1683 Set<TimeUnit> patternUnits
1684 ) {
1685 super();
1686
1687 if (duration == null) {
1688 throw new NullPointerException();
1689 }
1690
1691 this.duration = duration;
1692 this.patternUnits = patternUnits;
1693
1694 }
1695
1696 //~ Methoden ------------------------------------------------------
1697
1698 @Override
1699 public List<Item<TimeUnit>> getTotalLength() {
1700 throw new AssertionError("Never called.");
1701 }
1702
1703 @Override
1704 public boolean contains(TimeUnit unit) {
1705 return true;
1706 }
1707
1708 @Override
1709 public long getPartialAmount(TimeUnit unit) {
1710
1711 if (unit == TimeUnit.NANOSECONDS) {
1712 return this.duration.getPartialAmount(TimeUnit.NANOSECONDS);
1713 }
1714
1715 long days = 0L;
1716 long hours = 0L;
1717 long minutes = 0L;
1718 long seconds = this.duration.getPartialAmount(TimeUnit.SECONDS);
1719
1720 if (this.patternUnits.contains(TimeUnit.DAYS)) {
1721 days = seconds / 86400;
1722 seconds -= (days * 86400);
1723 }
1724
1725 if (this.patternUnits.contains(TimeUnit.HOURS)) {
1726 hours = seconds / 3600;
1727 seconds -= (hours * 3600);
1728 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected