29
29
* broken into two components microseconds and nanoFractions, where nanoFractions can range from
30
30
* [-999, 999]. Internally, Spanner supports Interval value with the following range of individual
31
31
* fields: months: [-120000, 120000] days: [-3660000, 3660000] nanoseconds: [-316224000000000000000,
32
- * 316224000000000000000] Interval value created outside the specified domain will return error when
32
+ * 316224000000000000000]. Interval value created outside the specified domain will return error when
33
33
* sent to Spanner backend.
34
34
*/
35
35
@ Immutable
@@ -43,21 +43,19 @@ public class Interval implements Serializable {
43
43
public static final long SECONDS_PER_MINUTE = 60 ;
44
44
public static final long SECONDS_PER_HOUR = MINUTES_PER_HOUR * SECONDS_PER_MINUTE ;
45
45
public static final long MILLIS_PER_SECOND = 1000 ;
46
- public static final long MICROS_PER_MILLI = 1000 ;
47
- public static final long NANOS_PER_MICRO = 1000 ;
48
- public static final long MICROS_PER_SECOND = MICROS_PER_MILLI * MILLIS_PER_SECOND ;
46
+ public static final long MICROS_PER_MILLISECOND = 1000 ;
47
+ public static final long MICROS_PER_SECOND = MICROS_PER_MILLISECOND * MILLIS_PER_SECOND ;
49
48
public static final long MICROS_PER_MINUTE = SECONDS_PER_MINUTE * MICROS_PER_SECOND ;
50
49
public static final long MICROS_PER_HOUR = SECONDS_PER_HOUR * MICROS_PER_SECOND ;
51
- public static final BigInteger NANOS_PER_MICROSECOND =
52
- BigInteger .valueOf (MICROS_PER_SECOND * NANOS_PER_MICRO );
50
+ public static final long NANOS_PER_MICROSECOND = 1000 ;
53
51
public static final BigInteger NANOS_PER_MILLISECOND =
54
- BigInteger .valueOf (MILLIS_PER_SECOND * NANOS_PER_MICRO );
52
+ BigInteger .valueOf (MICROS_PER_MILLISECOND * NANOS_PER_MICROSECOND );
55
53
public static final BigInteger NANOS_PER_SECOND =
56
- BigInteger .valueOf (MICROS_PER_SECOND * NANOS_PER_MICRO );
54
+ BigInteger .valueOf (MICROS_PER_SECOND * NANOS_PER_MICROSECOND );
57
55
public static final BigInteger NANOS_PER_MINUTE =
58
- BigInteger .valueOf (MICROS_PER_MINUTE * NANOS_PER_MICRO );
56
+ BigInteger .valueOf (MICROS_PER_MINUTE * NANOS_PER_MICROSECOND );
59
57
public static final BigInteger NANOS_PER_HOUR =
60
- BigInteger .valueOf (MICROS_PER_HOUR * NANOS_PER_MICRO );
58
+ BigInteger .valueOf (MICROS_PER_HOUR * NANOS_PER_MICROSECOND );
61
59
public static final Interval ZERO = Interval .builder ().build ();
62
60
63
61
/** Regex to parse ISO8601 interval format- `P[n]Y[n]M[n]DT[n]H[n]M[n([.,][fraction])]S` */
@@ -115,7 +113,7 @@ public static Interval ofMilliseconds(long milliseconds) {
115
113
/** Creates an interval with specified number of microseconds. */
116
114
public static Interval ofMicroseconds (long micros ) {
117
115
return builder ()
118
- .setNanoseconds (BigInteger .valueOf (micros ).multiply (NANOS_PER_MICROSECOND ))
116
+ .setNanoseconds (BigInteger .valueOf (micros ).multiply (BigInteger . valueOf ( NANOS_PER_MICROSECOND ) ))
119
117
.build ();
120
118
}
121
119
0 commit comments