wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
/**
 * @copyright (c) 2016-present, Philipp Thürwächter & Pattrick Hüper  & js-joda contributors
 * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
 * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
 */
 
import { ChronoField } from './temporal/ChronoField';
import { ChronoUnit } from './temporal/ChronoUnit';
import { Temporal } from './temporal/Temporal';
import { Clock } from './Clock';
import { DateTimeFormatter } from './format/DateTimeFormatter';
import { Instant } from './Instant';
import { IsoChronology } from './chrono/IsoChronology';
import { LocalDateTime } from './LocalDateTime';
import { LocalDate } from './LocalDate';
import { LocalTime } from './LocalTime';
import { MathUtil } from './MathUtil';
import { OffsetTime } from './OffsetTime';
import { TemporalQueries } from './temporal/TemporalQueries';
import { ZonedDateTime } from './ZonedDateTime';
import { ZoneId } from './ZoneId';
import { ZoneOffset } from './ZoneOffset';
import { DateTimeException, IllegalArgumentException } from './errors';
 
import { createTemporalQuery } from './temporal/TemporalQuery';
import { requireInstance, requireNonNull } from './assert';
 
/**
 * A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system,
 * such as 2007-12-23T10:15:30+01:00.
 */
export class OffsetDateTime extends Temporal {
    /**
     * @param {TemporaroAccessor} temporal
     * @return {OffsetDateTime}
     */
    static from(temporal) {
        requireNonNull(temporal, 'temporal');
        if (temporal instanceof OffsetDateTime) {
            return temporal;
        }
        try {
            const offset = ZoneOffset.from(temporal);
            try {
                const ldt = LocalDateTime.from(temporal);
                return OffsetDateTime.of(ldt, offset);
            } catch (_) {
                const instant = Instant.from(temporal);
                return OffsetDateTime.ofInstant(instant, offset);
            }
        } catch (ex) {
            throw new DateTimeException(`Unable to obtain OffsetDateTime TemporalAccessor: ${temporal}, type ${temporal.constructor != null ? temporal.constructor.name : ''}`);
        }
    }
 
    /**
     * @param {Clock|ZoneId|null} clockOrZone
     * @return {OffsetDateTime}
     */
    static now(clockOrZone) {
        if (arguments.length === 0) {
            return OffsetDateTime.now(Clock.systemDefaultZone());
        } else {
            requireNonNull(clockOrZone, 'clockOrZone');
            if (clockOrZone instanceof ZoneId) {
                return OffsetDateTime.now(Clock.system(clockOrZone));
            } else if (clockOrZone instanceof Clock) {
                const now = clockOrZone.instant(); // called once
                return OffsetDateTime.ofInstant(now, clockOrZone.zone().rules().offset(now));
            } else {
                throw new IllegalArgumentException('clockOrZone must be an instance of ZoneId or Clock');
            }
        }
    }
 
    /**
     * @return {OffsetDateTime}
     */
    static of() {
        if (arguments.length <= 2) {
            return OffsetDateTime.ofDateTime.apply(this, arguments);
        } else if (arguments.length === 3) {
            return OffsetDateTime.ofDateAndTime.apply(this, arguments);
        } else {
            return OffsetDateTime.ofNumbers.apply(this, arguments);
        }
    }
 
    static ofDateTime(dateTime, offset) {
        return new OffsetDateTime(dateTime, offset);
    }
 
    static ofDateAndTime(date, time, offset) {
        const dt = LocalDateTime.of(date, time);
        return new OffsetDateTime(dt, offset);
    }
 
    static ofNumbers(year, month, dayOfMonth, hour=0, minute=0, second=0, nanoOfSecond=0, offset) {
        const dt = LocalDateTime.of(year, month, dayOfMonth, hour, minute, second, nanoOfSecond);
        return new OffsetDateTime(dt, offset);
    }
 
    /**
     * @param {Instant} instant
     * @param {ZoneId} zone
     * @return {OffsetDateTime}
     */
    static ofInstant(instant,  zone){
        requireNonNull(instant, 'instant');
        requireNonNull(zone, 'zone');
        const rules = zone.rules();
        const offset = rules.offset(instant);
        const ldt = LocalDateTime.ofEpochSecond(instant.epochSecond(), instant.nano(), offset);
        return new OffsetDateTime(ldt, offset);
    }
 
    /**
     * @param {string} text
     * @param {DateTimeFormatter|undefined} formatter
     * @return {OffsetTime}
     */
    static parse(text, formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME){
        requireNonNull(formatter, 'formatter');
        return formatter.parse(text, OffsetDateTime.FROM);
    }
 
    // TODO: Need java.util.Comparater interface.
    // static timeLineOrder() {
    //
    // }
 
    //-----------------------------------------------------------------------
 
 
    /**
     * @param {LocalDateTime} dateTime
     * @param {ZoneOffset} offset
     * @private
     */
    constructor(dateTime, offset) {
        super();
        requireNonNull(dateTime, 'dateTime');
        requireInstance(dateTime, LocalDateTime, 'dateTime');
        requireNonNull(offset, 'offset');
        requireInstance(offset, ZoneOffset, 'offset');
        this._dateTime = dateTime;
        this._offset = offset;
    }
 
    /**
     *
     * @param {Temporal} temporal
     * @return {Temporal}
     */
    adjustInto(temporal) {
        return temporal
            .with(ChronoField.EPOCH_DAY, this.toLocalDate().toEpochDay())
            .with(ChronoField.NANO_OF_DAY, this.toLocalTime().toNanoOfDay())
            .with(ChronoField.OFFSET_SECONDS, this.offset().totalSeconds());
    }
 
    until(endExclusive, unit) {
        let end = OffsetDateTime.from(endExclusive);
        if (unit instanceof ChronoUnit) {
            end = end.withOffsetSameInstant(this._offset);
            return this._dateTime.until(end._dateTime, unit);
        }
        return unit.between(this, end);
    }
 
    /**
     * @param {ZoneId} zone
     * @return {ZonedDateTime}
     */
    atZoneSameInstant(zone) {
        return ZonedDateTime.ofInstant(this._dateTime, this._offset, zone);
    }
 
    /**
     * @param {ZoneId} zone
     * @return {ZonedDateTime}
     */
    atZoneSimilarLocal(zone) {
        return ZonedDateTime.ofLocal(this._dateTime, zone, this._offset);
    }
 
    query(query) {
        requireNonNull(query, 'query');
        if (query === TemporalQueries.chronology()) {
            return IsoChronology.INSTANCE;
        } else if (query === TemporalQueries.precision()) {
            return ChronoUnit.NANOS;
        } else if (query === TemporalQueries.offset() || query === TemporalQueries.zone()) {
            return this.offset();
        } else if (query === TemporalQueries.localDate()) {
            return this.toLocalDate();
        } else if (query === TemporalQueries.localTime()) {
            return this.toLocalTime();
        } else if (query === TemporalQueries.zoneId()) {
            return null;
        }
        return super.query(query);
    }
 
    get(field) {
        if (field instanceof ChronoField) {
            switch (field) {
                case ChronoField.INSTANT_SECONDS: throw new DateTimeException(`Field too large for an int: ${field}`);
                case ChronoField.OFFSET_SECONDS: return this.offset().totalSeconds();
            }
            return this._dateTime.get(field);
        }
        return super.get(field);
    }
 
    getLong(field) {
        if (field instanceof ChronoField) {
            switch (field) {
                case ChronoField.INSTANT_SECONDS: return this.toEpochSecond();
                case ChronoField.OFFSET_SECONDS: return this.offset().totalSeconds();
            }
            return this._dateTime.getLong(field);
        }
        return field.getFrom(this);
    }
 
    /**
     * @return {ZoneOffset}
     */
    offset() {
        return this._offset;
    }
 
    /**
     * @return {number} the year, from MIN_YEAR to MAX_YEAR
     */
    year() {
        return this._dateTime.year();
    }
 
    /**
     * @return {number} the month-of-year, from 1 to 12
     * @see #month()
     */
    monthValue() {
        return this._dateTime.monthValue();
    }
 
    /**
     * @return {{number} }the month-of-year, not null
     * @see #monthValue()
     */
    month() {
        return this._dateTime.month();
    }
 
    /**
     * @return {number} the day-of-month, from 1 to 31
     */
    dayOfMonth() {
        return this._dateTime.dayOfMonth();
    }
 
    /**
     * @return {number} the day-of-year, from 1 to 365, or 366 in a leap year
     */
    dayOfYear() {
        return this._dateTime.dayOfYear();
    }
 
    /**
     * @return {number} the day-of-week, not null
     */
    dayOfWeek() {
        return this._dateTime.dayOfWeek();
    }
 
    /**
     * @return {number} the hour-of-day, from 0 to 23
     */
    hour() {
        return this._dateTime.hour();
    }
 
    /**
     * @return {number} the minute-of-hour, from 0 to 59
     */
    minute() {
        return this._dateTime.minute();
    }
 
    /**
     * @return {number} the second-of-minute, from 0 to 59
     */
    second() {
        return this._dateTime.second();
    }
 
    /**
     * @return {number} the nano-of-second, from 0 to 999,999,999
     */
    nano() {
        return this._dateTime.nano();
    }
 
    //-----------------------------------------------------------------------
    /**
     * @return {LocalDateTime}the local date-time part of this date-time, not null
     */
    toLocalDateTime() {
        return this._dateTime;
    }
 
    /**
     * @return {LocalDate} the date part of this date-time, not null
     */
    toLocalDate() {
        return this._dateTime.toLocalDate();
    }
 
    /**
     * @return {LocalTime} the time part of this date-time, not null
     */
    toLocalTime() {
        return this._dateTime.toLocalTime();
    }
 
    /**
     * @return {OffsetTime} an OffsetTime representing the time and offset, not null
     */
    toOffsetTime() {
        return OffsetTime.of(this._dateTime.toLocalTime(), this._offset);
    }
 
    /**
     * @return {ZonedDateTime}a zoned date-time representing the same local date-time and offset, not null
     */
    toZonedDateTime() {
        return ZonedDateTime.of(this._dateTime, this._offset);
    }
 
    /**
     * @return {Instant} an {@code Instant} representing the same instant, not null
     */
    toInstant() {
        return this._dateTime.toInstant(this._offset);
    }
 
    /**
     * @return {number} the number of seconds from the epoch of 1970-01-01T00:00:00Z
     */
    toEpochSecond() {
        return this._dateTime.toEpochSecond(this._offset);
    }
 
    isSupported(fieldOrUnit) {
        if (fieldOrUnit instanceof ChronoField) {
            return fieldOrUnit.isDateBased() || fieldOrUnit.isTimeBased();
        }
        if (fieldOrUnit instanceof ChronoUnit) {
            return fieldOrUnit.isDateBased() || fieldOrUnit.isTimeBased();
        }
        return fieldOrUnit != null && fieldOrUnit.isSupportedBy(this);
    }
 
    range(field) {
        if (field instanceof ChronoField) {
            if (field === ChronoField.INSTANT_SECONDS || field === ChronoField.OFFSET_SECONDS) {
                return field.range();
            }
            return this._dateTime.range(field);
        }
        return field.rangeRefinedBy(this);
    }
 
    _withAdjuster(adjuster) {
        requireNonNull(adjuster);
        // optimizations
        if (adjuster instanceof LocalDate || adjuster instanceof LocalTime || adjuster instanceof LocalDateTime) {
            return this._withDateTimeOffset(this._dateTime.with(adjuster), this._offset);
        } else if (adjuster instanceof Instant) {
            return OffsetDateTime.ofInstant(adjuster, this._offset);
        } else if (adjuster instanceof ZoneOffset) {
            return this._withDateTimeOffset(this._dateTime, adjuster);
        } else if (adjuster instanceof OffsetDateTime) {
            return adjuster;
        }
        return adjuster.adjustInto(this);
    }
 
    _withField(field, newValue) {
        requireNonNull(field);
        if (field instanceof ChronoField) {
            const f = field;
            switch (f) {
                case ChronoField.INSTANT_SECONDS: return OffsetDateTime.ofInstant(Instant.ofEpochSecond(newValue, this.nano()), this._offset);
                case ChronoField.OFFSET_SECONDS: {
                    return this._withDateTimeOffset(this._dateTime, ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue)));
                }
            }
            return this._withDateTimeOffset(this._dateTime.with(field, newValue), this._offset);
        }
        return field.adjustInto(this, newValue);
    }
 
    _withDateTimeOffset(dateTime, offset) {
        if (this._dateTime === dateTime && this._offset.equals(offset)) {
            return this;
        }
        return new OffsetDateTime(dateTime, offset);
    }
 
    /**
     * @param {int} year
     * @return {OffsetDateTime}
     */
    withYear(year) {
        return this._withDateTimeOffset(this._dateTime.withYear(year), this._offset);
    }
 
    /**
     * @param {int} month
     * @return {OffsetDateTime}
     */
    withMonth(month) {
        return this._withDateTimeOffset(this._dateTime.withMonth(month), this._offset);
    }
 
    /**
     * @param {int} dayOfMonth
     * @return {OffsetDateTime}
     */
    withDayOfMonth(dayOfMonth) {
        return this._withDateTimeOffset(this._dateTime.withDayOfMonth(dayOfMonth), this._offset);
    }
 
    /**
     * @param {int} dayOfYear
     * @return {OffsetDateTime}
     */
    withDayOfYear(dayOfYear) {
        return this._withDateTimeOffset(this._dateTime.withDayOfYear(dayOfYear), this._offset);
    }
 
    /**
     * @param {int} hour
     * @return {OffsetDateTime}
     */
    withHour(hour) {
        return this._withDateTimeOffset(this._dateTime.withHour(hour), this._offset);
    }
 
    /**
     * @param {int} minute
     * @return {OffsetDateTime}
     */
    withMinute(minute) {
        return this._withDateTimeOffset(this._dateTime.withMinute(minute), this._offset);
    }
 
    /**
     * @param {int} second
     * @return {OffsetDateTime}
     */
    withSecond(second) {
        return this._withDateTimeOffset(this._dateTime.withSecond(second), this._offset);
    }
 
    /**
     * @param {int} nanoOfSecond
     * @return {OffsetDateTime}
     */
    withNano(nanoOfSecond) {
        return this._withDateTimeOffset(this._dateTime.withNano(nanoOfSecond), this._offset);
    }
 
    /**
     * @param {ZoneOffset} offset
     * @return {OffsetDateTime}
     */
    withOffsetSameLocal(offset) {
        requireNonNull(offset, 'offset');
        return this._withDateTimeOffset(this._dateTime, offset);
    }
 
    /**
     * @param {ZoneOffset} offset
     * @return {OffsetDateTime}
     */
    withOffsetSameInstant(offset) {
        requireNonNull(offset, 'offset');
        if (offset.equals(this._offset)) {
            return this;
        }
        const difference = offset.totalSeconds() - this._offset.totalSeconds();
        const adjusted = this._dateTime.plusSeconds(difference);
        return new OffsetDateTime(adjusted, offset);
    }
 
    /**
     * @param {TemporalUnit} unit
     * @return {OffsetDateTime}
     */
    truncatedTo(unit) {
        return this._withDateTimeOffset(this._dateTime.truncatedTo(unit), this._offset);
    }
 
    _plusAmount(amount) {
        requireNonNull(amount, 'amount');
        return amount.addTo(this);
    }
 
    _plusUnit(amountToAdd, unit) {
        if (unit instanceof ChronoUnit) {
            return this._withDateTimeOffset(this._dateTime.plus(amountToAdd, unit), this._offset);
        }
        return unit.addTo(this, amountToAdd);
    }
 
    /**
     * @param {int} years
     * @return {OffsetTime}
     */
    plusYears(years) {
        return this._withDateTimeOffset(this._dateTime.plusYears(years), this._offset);
    }
 
    /**
     * @param {int} months
     * @return {OffsetTime}
     */
    plusMonths(months) {
        return this._withDateTimeOffset(this._dateTime.plusMonths(months), this._offset);
    }
 
    /**
     * @param {int} weeks
     * @return {OffsetTime}
     */
    plusWeeks(weeks) {
        return this._withDateTimeOffset(this._dateTime.plusWeeks(weeks), this._offset);
    }
 
    /**
     * @param {int} days
     * @return {OffsetTime}
     */
    plusDays(days) {
        return this._withDateTimeOffset(this._dateTime.plusDays(days), this._offset);
    }
 
    /**
     * @param {int} hours
     * @return {OffsetTime}
     */
    plusHours(hours) {
        return this._withDateTimeOffset(this._dateTime.plusHours(hours), this._offset);
    }
 
    /**
     * @param {int} minutes
     * @return {OffsetTime}
     */
    plusMinutes(minutes) {
        return this._withDateTimeOffset(this._dateTime.plusMinutes(minutes), this._offset);
    }
 
    /**
     * @param {int} seconds
     * @return {OffsetTime}
     */
    plusSeconds(seconds) {
        return this._withDateTimeOffset(this._dateTime.plusSeconds(seconds), this._offset);
    }
 
    /**
     * @param {int} nanos
     * @return {OffsetTime}
     */
    plusNanos(nanos) {
        return this._withDateTimeOffset(this._dateTime.plusNanos(nanos), this._offset);
    }
 
    _minusAmount(amount) {
        requireNonNull(amount);
        return amount.subtractFrom(this);
    }
 
    _minusUnit(amountToSubtract, unit) {
        return this.plus(-1 * amountToSubtract, unit);
    }
 
    /**
     * @param {int} years
     * @return {OffsetTime}
     */
    minusYears(years) {
        return this._withDateTimeOffset(this._dateTime.minusYears(years), this._offset);
    }
 
    /**
     * @param {int} months
     * @return {OffsetTime}
     */
    minusMonths(months) {
        return this._withDateTimeOffset(this._dateTime.minusMonths(months), this._offset);
    }
 
    /**
     * @param {int} weeks
     * @return {OffsetTime}
     */
    minusWeeks(weeks) {
        return this._withDateTimeOffset(this._dateTime.minusWeeks(weeks), this._offset);
    }
 
    /**
     * @param {int} days
     * @return {OffsetTime}
     */
    minusDays(days) {
        return this._withDateTimeOffset(this._dateTime.minusDays(days), this._offset);
    }
 
    /**
     * @param {int} hours
     * @return {OffsetTime}
     */
    minusHours(hours) {
        return this._withDateTimeOffset(this._dateTime.minusHours(hours), this._offset);
    }
 
    /**
     * @param {int} minutes
     * @return {OffsetTime}
     */
    minusMinutes(minutes) {
        return this._withDateTimeOffset(this._dateTime.minusMinutes(minutes), this._offset);
    }
 
    /**
     * @param {int} seconds
     * @return {OffsetTime}
     */
    minusSeconds(seconds) {
        return this._withDateTimeOffset(this._dateTime.minusSeconds(seconds), this._offset);
    }
 
    /**
     * @param {int} nanos
     * @return {OffsetTime}
     */
    minusNanos(nanos) {
        return this._withDateTimeOffset(this._dateTime.minusNanos(nanos), this._offset);
    }
 
    compareTo(other) {
        requireNonNull(other, 'other');
        requireInstance(other, OffsetDateTime, 'other');
        if (this.offset().equals(other.offset())) {
            return this.toLocalDateTime().compareTo(other.toLocalDateTime());
        }
        let cmp = MathUtil.compareNumbers(this.toEpochSecond(), other.toEpochSecond());
        if (cmp === 0) {
            cmp = this.toLocalTime().nano() - other.toLocalTime().nano();
            if (cmp === 0) {
                cmp = this.toLocalDateTime().compareTo(other.toLocalDateTime());
            }
        }
        return cmp;
    }
 
    /**
     * @param {OffsetDateTime} other
     * @return {boolean}
     */
    isAfter(other) {
        requireNonNull(other, 'other');
        const thisEpochSec = this.toEpochSecond();
        const otherEpochSec = other.toEpochSecond();
        return thisEpochSec > otherEpochSec || (thisEpochSec === otherEpochSec && this.toLocalTime().nano() > other.toLocalTime().nano());
    }
 
    /**
     * @param {OffsetDateTime} other
     * @return {boolean}
     */
    isBefore(other) {
        requireNonNull(other, 'other');
        const thisEpochSec = this.toEpochSecond();
        const otherEpochSec = other.toEpochSecond();
        return thisEpochSec < otherEpochSec || (thisEpochSec === otherEpochSec && this.toLocalTime().nano() < other.toLocalTime().nano());
    }
 
    /**
     * @param {OffsetDateTime} other
     * @return {boolean}
     */
    isEqual(other) {
        requireNonNull(other, 'other');
        return this.toEpochSecond() === other.toEpochSecond() && this.toLocalTime().nano() === other.toLocalTime().nano();
    }
 
    //-----------------------------------------------------------------------
    /**
     * @param other
     * @return {boolean}
     */
    equals(other) {
        if (this === other) {
            return true;
        }
        if (other instanceof OffsetDateTime) {
            return this._dateTime.equals(other._dateTime) && this._offset.equals(other._offset);
        }
        return false;
    }
 
    /**
     * @return {number}
     */
    hashCode() {
        return this._dateTime.hashCode() ^ this._offset.hashCode();
    }
 
    toString() {
        return this._dateTime.toString() + this._offset.toString();
    }
 
    /**
     *
     * @return {string} same as {@link LocalDateTime.toString}
     */
    toJSON() {
        return this.toString();
    }
 
    /**
     * @param {DateTimeFormatter} formatter
     * @return {string}
     */
    format(formatter) {
        requireNonNull(formatter, 'formatter');
        return formatter.format(this);
    }
}
 
 
export function _init() {
    OffsetDateTime.MIN = LocalDateTime.MIN.atOffset(ZoneOffset.MAX);
 
    OffsetDateTime.MAX = LocalDateTime.MAX.atOffset(ZoneOffset.MIN);
 
    OffsetDateTime.FROM = createTemporalQuery('OffsetDateTime.FROM', (temporal) => {
        return OffsetDateTime.from(temporal);
    });
}