| 54 | * @author Meno Hochschild |
| 55 | */ |
| 56 | public enum SI |
| 57 | implements ChronoUnit { |
| 58 | |
| 59 | //~ Statische Felder/Initialisierungen -------------------------------- |
| 60 | |
| 61 | SECONDS(1.0), |
| 62 | |
| 63 | NANOSECONDS(1.0 / 1000000000); |
| 64 | |
| 65 | //~ Instanzvariablen -------------------------------------------------- |
| 66 | |
| 67 | private final double length; |
| 68 | |
| 69 | //~ Konstruktoren ----------------------------------------------------- |
| 70 | |
| 71 | private SI(double length) { |
| 72 | this.length = length; |
| 73 | } |
| 74 | |
| 75 | //~ Methoden ---------------------------------------------------------- |
| 76 | |
| 77 | /** |
| 78 | * <p>Calculates the time distance between given time points |
| 79 | * in SI-units. </p> |
| 80 | * |
| 81 | * @param start start time point |
| 82 | * @param end end time point |
| 83 | * @return count of SI-units between start and end |
| 84 | * @throws UnsupportedOperationException if any time point is before 1972 |
| 85 | */ |
| 86 | /*[deutsch] |
| 87 | * <p>Berechnet den zeitlichen Abstand zwischen den angegebenen Zeitpunkten |
| 88 | * in SI-Einheiten. </p> |
| 89 | * |
| 90 | * @param start Startzeitpunkt |
| 91 | * @param end Endzeitpunkt |
| 92 | * @return Anzahl der SI-Einheiten zwischen Start und Ende |
| 93 | * @throws UnsupportedOperationException wenn ein Zeitpunkt vor 1972 ist |
| 94 | */ |
| 95 | public long between( |
| 96 | Moment start, |
| 97 | Moment end |
| 98 | ) { |
| 99 | |
| 100 | Moment.check1972(start); |
| 101 | Moment.check1972(end); |
| 102 | |
| 103 | switch (this) { |
| 104 | case SECONDS: |
| 105 | long delta = ( |
| 106 | end.getElapsedTime(TimeScale.UTC) |
| 107 | - start.getElapsedTime(TimeScale.UTC)); |
| 108 | if (delta < 0) { |
| 109 | if (end.getNanosecond() > start.getNanosecond()) { |
| 110 | delta++; |
| 111 | } |
| 112 | } else if (delta > 0) { |
| 113 | if (end.getNanosecond() < start.getNanosecond()) { |
nothing calls this directly
no outgoing calls
no test coverage detected