@@ -83,7 +83,7 @@ default CalendarDate adjustInto(final CalendarDate temporal) {
83
83
default long adjustInto (final long epochMilli ) {
84
84
long duration = this .toDurationInMillis ();
85
85
long half = duration / 2L ;
86
- return (( epochMilli / duration ) * duration ) + half ;
86
+ return epochMilli / duration * duration + half ;
87
87
}
88
88
89
89
/**
@@ -95,10 +95,12 @@ default long toDurationInNanos() {
95
95
return this .toDurationInMillis () * NANOS_PER_MILLIS ;
96
96
}
97
97
98
+ @ Override
98
99
default long toIndex (final CalendarDate key ) {
99
100
return this .adjustInto (key .millis );
100
101
}
101
102
103
+ @ Override
102
104
default CalendarDate toKey (final long index ) {
103
105
return new CalendarDate (index );
104
106
}
@@ -120,7 +122,7 @@ public static CalendarDate from(final TemporalAccessor temporal) {
120
122
try {
121
123
long tmpSeconds = temporal .getLong (ChronoField .INSTANT_SECONDS );
122
124
int tmpMillisOfSecond = temporal .get (ChronoField .MILLI_OF_SECOND );
123
- return new CalendarDate (( tmpSeconds * MILLIS_PER_SECOND ) + tmpMillisOfSecond );
125
+ return new CalendarDate (tmpSeconds * MILLIS_PER_SECOND + tmpMillisOfSecond );
124
126
} catch (DateTimeException ex ) {
125
127
throw new DateTimeException ("Unable to obtain CalendarDate from TemporalAccessor: " + temporal + " of type " + temporal .getClass ().getName (),
126
128
ex );
@@ -232,7 +234,7 @@ static long millis(final TemporalAccessor temporal) {
232
234
try {
233
235
long tmpSeconds = temporal .getLong (ChronoField .INSTANT_SECONDS );
234
236
int tmpMillisOfSecond = temporal .get (ChronoField .MILLI_OF_SECOND );
235
- return ( tmpSeconds * MILLIS_PER_SECOND ) + tmpMillisOfSecond ;
237
+ return tmpSeconds * MILLIS_PER_SECOND + tmpMillisOfSecond ;
236
238
} catch (DateTimeException ex ) {
237
239
throw new DateTimeException ("No millis!" );
238
240
}
@@ -312,11 +314,12 @@ public <T extends Temporal> T adjustInto(final T temporal) {
312
314
return (T ) this ;
313
315
} else {
314
316
long seconds = millis / MILLIS_PER_SECOND ;
315
- long nanos = ( millis % MILLIS_PER_SECOND ) * (NANOS_PER_SECOND / MILLIS_PER_SECOND );
317
+ long nanos = millis % MILLIS_PER_SECOND * (NANOS_PER_SECOND / MILLIS_PER_SECOND );
316
318
return (T ) temporal .with (INSTANT_SECONDS , seconds ).with (NANO_OF_SECOND , nanos );
317
319
}
318
320
}
319
321
322
+ @ Override
320
323
public int compareTo (final CalendarDate ref ) {
321
324
return Long .signum (millis - ref .millis );
322
325
}
@@ -326,7 +329,7 @@ public boolean equals(final Object obj) {
326
329
if (this == obj ) {
327
330
return true ;
328
331
}
329
- if (( obj == null ) || !(obj instanceof CalendarDate )) {
332
+ if (obj == null || !(obj instanceof CalendarDate )) {
330
333
return false ;
331
334
}
332
335
CalendarDate other = (CalendarDate ) obj ;
@@ -344,6 +347,7 @@ public CalendarDate filter(final CalendarDateUnit resolution) {
344
347
}
345
348
}
346
349
350
+ @ Override
347
351
public long getLong (final TemporalField field ) {
348
352
if (field instanceof ChronoField ) {
349
353
if (field == ChronoField .INSTANT_SECONDS ) {
@@ -358,29 +362,32 @@ public long getLong(final TemporalField field) {
358
362
359
363
@ Override
360
364
public int hashCode () {
361
- return (int ) (millis ^ ( millis >>> 32 ) );
365
+ return (int ) (millis ^ millis >>> 32 );
362
366
}
363
367
368
+ @ Override
364
369
public boolean isSupported (final TemporalField field ) {
365
370
if (field instanceof ChronoField ) {
366
- return ( field == ChronoField .INSTANT_SECONDS ) || ( field == ChronoField .MILLI_OF_SECOND ) ;
371
+ return field == ChronoField .INSTANT_SECONDS || field == ChronoField .MILLI_OF_SECOND ;
367
372
} else {
368
373
return field .isSupportedBy (this );
369
374
}
370
375
}
371
376
377
+ @ Override
372
378
public boolean isSupported (final TemporalUnit unit ) {
373
379
if (unit instanceof CalendarDateUnit ) {
374
380
return true ;
375
381
} else if (unit instanceof ChronoUnit ) {
376
- return unit .isTimeBased () || ( unit == ChronoUnit .DAYS ) ;
382
+ return unit .isTimeBased () || unit == ChronoUnit .DAYS ;
377
383
} else if (unit != null ) {
378
384
return unit .isSupportedBy (this );
379
385
} else {
380
386
return false ;
381
387
}
382
388
}
383
389
390
+ @ Override
384
391
public Temporal plus (final long amountToAdd , final TemporalUnit unit ) {
385
392
if (unit instanceof CalendarDateUnit ) {
386
393
return this .step ((int ) amountToAdd , (CalendarDateUnit ) unit );
@@ -403,7 +410,7 @@ public CalendarDate step(final CalendarDateUnit aStepUnit) {
403
410
}
404
411
405
412
public CalendarDate step (final int aStepCount , final CalendarDateUnit aStepUnit ) {
406
- return new CalendarDate (millis + ( aStepCount * aStepUnit .toDurationInMillis () ));
413
+ return new CalendarDate (millis + aStepCount * aStepUnit .toDurationInMillis ());
407
414
}
408
415
409
416
public Calendar toCalendar () {
@@ -456,7 +463,7 @@ public LocalTime toLocalTime(final ZoneOffset offset) {
456
463
int tmpNanos = (int ) Math .floorMod (millis , MILLIS_PER_SECOND );
457
464
long tmpLocalSeconds = tmpSeconds + offset .getTotalSeconds ();
458
465
int tmpSecondOfDay = (int ) Math .floorMod (tmpLocalSeconds , CalendarDate .SECONDS_PER_DAY );
459
- int tmpNanoOfDay = ( tmpSecondOfDay * CalendarDate .NANOS_PER_SECOND ) + tmpNanos ;
466
+ int tmpNanoOfDay = tmpSecondOfDay * CalendarDate .NANOS_PER_SECOND + tmpNanos ;
460
467
return LocalTime .ofNanoOfDay (tmpNanoOfDay );
461
468
}
462
469
@@ -473,6 +480,7 @@ public ZonedDateTime toZonedDateTime(final ZoneOffset offset) {
473
480
return ZonedDateTime .of (this .toLocalDateTime (offset ), offset );
474
481
}
475
482
483
+ @ Override
476
484
public long until (final Temporal endExclusive , final TemporalUnit unit ) {
477
485
if (unit instanceof CalendarDateUnit ) {
478
486
return ((CalendarDateUnit ) unit ).count (millis , CalendarDate .millis (endExclusive ));
@@ -483,18 +491,20 @@ public long until(final Temporal endExclusive, final TemporalUnit unit) {
483
491
}
484
492
}
485
493
494
+ @ Override
486
495
public CalendarDate with (final TemporalAdjuster adjuster ) {
487
496
return (CalendarDate ) Temporal .super .with (adjuster );
488
497
}
489
498
499
+ @ Override
490
500
public CalendarDate with (final TemporalField field , final long newValue ) {
491
501
if (field instanceof ChronoField ) {
492
502
if (field == ChronoField .INSTANT_SECONDS ) {
493
503
long tmpMillisOfSecond = millis % MILLIS_PER_SECOND ;
494
- return new CalendarDate (( newValue * MILLIS_PER_SECOND ) + tmpMillisOfSecond );
504
+ return new CalendarDate (newValue * MILLIS_PER_SECOND + tmpMillisOfSecond );
495
505
} else if (field == ChronoField .MILLI_OF_SECOND ) {
496
506
long tmpSeconds = millis / MILLIS_PER_SECOND ;
497
- return new CalendarDate (( tmpSeconds * MILLIS_PER_SECOND ) + newValue );
507
+ return new CalendarDate (tmpSeconds * MILLIS_PER_SECOND + newValue );
498
508
} else {
499
509
throw new UnsupportedTemporalTypeException ("Unsupported field: " + field );
500
510
}
0 commit comments