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

Class ClockUnitRule

base/src/main/java/net/time4j/PlainTime.java:2129–2308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2127 //~ Innere Klassen ----------------------------------------------------
2128
2129 private static class ClockUnitRule
2130 implements UnitRule<PlainTime> {
2131
2132 //~ Instanzvariablen ----------------------------------------------
2133
2134 private final ClockUnit unit;
2135
2136 //~ Konstruktoren -------------------------------------------------
2137
2138 private ClockUnitRule(ClockUnit unit) {
2139 super();
2140
2141 this.unit = unit;
2142
2143 }
2144
2145 //~ Methoden ------------------------------------------------------
2146
2147 @Override
2148 public PlainTime addTo(
2149 PlainTime context,
2150 long amount
2151 ) {
2152
2153 if (amount == 0) {
2154 return context;
2155 }
2156
2157 return doAdd(PlainTime.class, this.unit, context, amount);
2158
2159 }
2160
2161 @Override
2162 public long between(
2163 PlainTime start,
2164 PlainTime end
2165 ) {
2166
2167 long delta = (end.getNanoOfDay() - start.getNanoOfDay());
2168 long factor;
2169
2170 switch (this.unit) {
2171 case HOURS:
2172 factor = MRD * 3600L;
2173 break;
2174 case MINUTES:
2175 factor = MRD * 60L;
2176 break;
2177 case SECONDS:
2178 factor = MRD;
2179 break;
2180 case MILLIS:
2181 factor = MIO;
2182 break;
2183 case MICROS:
2184 factor = KILO;
2185 break;
2186 case NANOS:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected