32
32
33
33
package org .opensearch .script ;
34
34
35
- import org .joda .time .DateTime ;
36
35
import org .opensearch .common .SuppressForbidden ;
37
- import org .opensearch .common .SuppressLoggerChecks ;
38
- import org .opensearch .common .logging .DeprecationLogger ;
39
36
import org .opensearch .common .time .DateFormatter ;
40
- import org .opensearch .common .time .DateFormatters ;
41
- import org .opensearch .common .time .DateUtils ;
42
37
43
- import java .security .AccessController ;
44
- import java .security .PrivilegedAction ;
45
38
import java .time .DayOfWeek ;
46
39
import java .time .Instant ;
47
40
import java .time .LocalDate ;
55
48
import java .time .chrono .ChronoZonedDateTime ;
56
49
import java .time .chrono .Chronology ;
57
50
import java .time .format .DateTimeFormatter ;
58
- import java .time .temporal .ChronoField ;
59
51
import java .time .temporal .Temporal ;
60
52
import java .time .temporal .TemporalAccessor ;
61
53
import java .time .temporal .TemporalAdjuster ;
64
56
import java .time .temporal .TemporalQuery ;
65
57
import java .time .temporal .TemporalUnit ;
66
58
import java .time .temporal .ValueRange ;
67
- import java .util .Locale ;
68
59
import java .util .Objects ;
69
60
70
61
/**
@@ -80,23 +71,6 @@ public class JodaCompatibleZonedDateTime
80
71
TemporalAccessor {
81
72
82
73
private static final DateFormatter DATE_FORMATTER = DateFormatter .forPattern ("strict_date_time" );
83
- private static final DeprecationLogger deprecationLogger = DeprecationLogger .getLogger (JodaCompatibleZonedDateTime .class );
84
-
85
- private static void logDeprecated (String key , String message , Object ... params ) {
86
- AccessController .doPrivileged (new PrivilegedAction <Void >() {
87
- @ SuppressLoggerChecks (reason = "safely delegates to logger" )
88
- @ Override
89
- public Void run () {
90
- deprecationLogger .deprecate (key , message , params );
91
- return null ;
92
- }
93
- });
94
- }
95
-
96
- private static void logDeprecatedMethod (String oldMethod , String newMethod ) {
97
- logDeprecated (oldMethod , "Use of the joda time method [{}] is deprecated. Use [{}] instead." , oldMethod , newMethod );
98
- }
99
-
100
74
private ZonedDateTime dt ;
101
75
102
76
public JodaCompatibleZonedDateTime (Instant instant , ZoneId zone ) {
@@ -427,120 +401,7 @@ public ZonedDateTime withZoneSameInstant(ZoneId zone) {
427
401
return dt .withZoneSameInstant (zone );
428
402
}
429
403
430
- @ Deprecated
431
- public long getMillis () {
432
- logDeprecatedMethod ("getMillis()" , "toInstant().toEpochMilli()" );
433
- return dt .toInstant ().toEpochMilli ();
434
- }
435
-
436
- @ Deprecated
437
- public int getCenturyOfEra () {
438
- logDeprecatedMethod ("getCenturyOfEra()" , "get(ChronoField.YEAR_OF_ERA) / 100" );
439
- return dt .get (ChronoField .YEAR_OF_ERA ) / 100 ;
440
- }
441
-
442
- @ Deprecated
443
- public int getEra () {
444
- logDeprecatedMethod ("getEra()" , "get(ChronoField.ERA)" );
445
- return dt .get (ChronoField .ERA );
446
- }
447
-
448
- @ Deprecated
449
- public int getHourOfDay () {
450
- logDeprecatedMethod ("getHourOfDay()" , "getHour()" );
451
- return dt .getHour ();
452
- }
453
-
454
- @ Deprecated
455
- public int getMillisOfDay () {
456
- logDeprecatedMethod ("getMillisOfDay()" , "get(ChronoField.MILLI_OF_DAY)" );
457
- return dt .get (ChronoField .MILLI_OF_DAY );
458
- }
459
-
460
- @ Deprecated
461
- public int getMillisOfSecond () {
462
- logDeprecatedMethod ("getMillisOfSecond()" , "get(ChronoField.MILLI_OF_SECOND)" );
463
- return dt .get (ChronoField .MILLI_OF_SECOND );
464
- }
465
-
466
- @ Deprecated
467
- public int getMinuteOfDay () {
468
- logDeprecatedMethod ("getMinuteOfDay()" , "get(ChronoField.MINUTE_OF_DAY)" );
469
- return dt .get (ChronoField .MINUTE_OF_DAY );
470
- }
471
-
472
- @ Deprecated
473
- public int getMinuteOfHour () {
474
- logDeprecatedMethod ("getMinuteOfHour()" , "getMinute()" );
475
- return dt .getMinute ();
476
- }
477
-
478
- @ Deprecated
479
- public int getMonthOfYear () {
480
- logDeprecatedMethod ("getMonthOfYear()" , "getMonthValue()" );
481
- return dt .getMonthValue ();
482
- }
483
-
484
- @ Deprecated
485
- public int getSecondOfDay () {
486
- logDeprecatedMethod ("getSecondOfDay()" , "get(ChronoField.SECOND_OF_DAY)" );
487
- return dt .get (ChronoField .SECOND_OF_DAY );
488
- }
489
-
490
- @ Deprecated
491
- public int getSecondOfMinute () {
492
- logDeprecatedMethod ("getSecondOfMinute()" , "getSecond()" );
493
- return dt .getSecond ();
494
- }
495
-
496
- @ Deprecated
497
- public int getWeekOfWeekyear () {
498
- logDeprecatedMethod ("getWeekOfWeekyear()" , "get(DateFormatters.WEEK_FIELDS_ROOT.weekOfWeekBasedYear())" );
499
- return dt .get (DateFormatters .WEEK_FIELDS_ROOT .weekOfWeekBasedYear ());
500
- }
501
-
502
- @ Deprecated
503
- public int getWeekyear () {
504
- logDeprecatedMethod ("getWeekyear()" , "get(DateFormatters.WEEK_FIELDS_ROOT.weekBasedYear())" );
505
- return dt .get (DateFormatters .WEEK_FIELDS_ROOT .weekBasedYear ());
506
- }
507
-
508
- @ Deprecated
509
- public int getYearOfCentury () {
510
- logDeprecatedMethod ("getYearOfCentury()" , "get(ChronoField.YEAR_OF_ERA) % 100" );
511
- return dt .get (ChronoField .YEAR_OF_ERA ) % 100 ;
512
- }
513
-
514
- @ Deprecated
515
- public int getYearOfEra () {
516
- logDeprecatedMethod ("getYearOfEra()" , "get(ChronoField.YEAR_OF_ERA)" );
517
- return dt .get (ChronoField .YEAR_OF_ERA );
518
- }
519
-
520
- @ Deprecated
521
- public String toString (String format ) {
522
- logDeprecatedMethod ("toString(String)" , "a DateTimeFormatter" );
523
- // TODO: replace with bwc formatter
524
- return new DateTime (dt .toInstant ().toEpochMilli (), DateUtils .zoneIdToDateTimeZone (dt .getZone ())).toString (format );
525
- }
526
-
527
- @ Deprecated
528
- public String toString (String format , Locale locale ) {
529
- logDeprecatedMethod ("toString(String,Locale)" , "a DateTimeFormatter" );
530
- // TODO: replace with bwc formatter
531
- return new DateTime (dt .toInstant ().toEpochMilli (), DateUtils .zoneIdToDateTimeZone (dt .getZone ())).toString (format , locale );
532
- }
533
-
534
404
public DayOfWeek getDayOfWeekEnum () {
535
405
return dt .getDayOfWeek ();
536
406
}
537
-
538
- @ Deprecated
539
- public int getDayOfWeek () {
540
- logDeprecated (
541
- "getDayOfWeek()" ,
542
- "The return type of [getDayOfWeek()] will change to an enum in 7.0. Use getDayOfWeekEnum().getValue()."
543
- );
544
- return dt .getDayOfWeek ().getValue ();
545
- }
546
407
}
0 commit comments