Period.java
19.6 KB
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
package org.joda.time;
import java.io.Serializable;
import org.joda.convert.FromString;
import org.joda.time.base.BasePeriod;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.field.FieldUtils;
import org.joda.time.format.ISOPeriodFormat;
import org.joda.time.format.PeriodFormatter;
public final class Period
extends BasePeriod
implements Serializable, ReadablePeriod
{
public static final Period ZERO = new Period();
private static final long serialVersionUID = 741052353876488155L;
public Period()
{
super(0L, null, null);
}
public Period(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
super(0, 0, 0, 0, paramInt1, paramInt2, paramInt3, paramInt4, PeriodType.standard());
}
public Period(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, int paramInt8)
{
super(paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7, paramInt8, PeriodType.standard());
}
public Period(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, int paramInt8, PeriodType paramPeriodType)
{
super(paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7, paramInt8, paramPeriodType);
}
public Period(long paramLong)
{
super(paramLong);
}
public Period(long paramLong1, long paramLong2)
{
super(paramLong1, paramLong2, null, null);
}
public Period(long paramLong1, long paramLong2, Chronology paramChronology)
{
super(paramLong1, paramLong2, null, paramChronology);
}
public Period(long paramLong1, long paramLong2, PeriodType paramPeriodType)
{
super(paramLong1, paramLong2, paramPeriodType, null);
}
public Period(long paramLong1, long paramLong2, PeriodType paramPeriodType, Chronology paramChronology)
{
super(paramLong1, paramLong2, paramPeriodType, paramChronology);
}
public Period(long paramLong, Chronology paramChronology)
{
super(paramLong, null, paramChronology);
}
public Period(long paramLong, PeriodType paramPeriodType)
{
super(paramLong, paramPeriodType, null);
}
public Period(long paramLong, PeriodType paramPeriodType, Chronology paramChronology)
{
super(paramLong, paramPeriodType, paramChronology);
}
public Period(Object paramObject)
{
super(paramObject, null, null);
}
public Period(Object paramObject, Chronology paramChronology)
{
super(paramObject, null, paramChronology);
}
public Period(Object paramObject, PeriodType paramPeriodType)
{
super(paramObject, paramPeriodType, null);
}
public Period(Object paramObject, PeriodType paramPeriodType, Chronology paramChronology)
{
super(paramObject, paramPeriodType, paramChronology);
}
public Period(ReadableDuration paramReadableDuration, ReadableInstant paramReadableInstant)
{
super(paramReadableDuration, paramReadableInstant, null);
}
public Period(ReadableDuration paramReadableDuration, ReadableInstant paramReadableInstant, PeriodType paramPeriodType)
{
super(paramReadableDuration, paramReadableInstant, paramPeriodType);
}
public Period(ReadableInstant paramReadableInstant, ReadableDuration paramReadableDuration)
{
super(paramReadableInstant, paramReadableDuration, null);
}
public Period(ReadableInstant paramReadableInstant, ReadableDuration paramReadableDuration, PeriodType paramPeriodType)
{
super(paramReadableInstant, paramReadableDuration, paramPeriodType);
}
public Period(ReadableInstant paramReadableInstant1, ReadableInstant paramReadableInstant2)
{
super(paramReadableInstant1, paramReadableInstant2, null);
}
public Period(ReadableInstant paramReadableInstant1, ReadableInstant paramReadableInstant2, PeriodType paramPeriodType)
{
super(paramReadableInstant1, paramReadableInstant2, paramPeriodType);
}
public Period(ReadablePartial paramReadablePartial1, ReadablePartial paramReadablePartial2)
{
super(paramReadablePartial1, paramReadablePartial2, null);
}
public Period(ReadablePartial paramReadablePartial1, ReadablePartial paramReadablePartial2, PeriodType paramPeriodType)
{
super(paramReadablePartial1, paramReadablePartial2, paramPeriodType);
}
private Period(int[] paramArrayOfInt, PeriodType paramPeriodType)
{
super(paramArrayOfInt, paramPeriodType);
}
private void a(String paramString)
{
if (getMonths() != 0) {
throw new UnsupportedOperationException("Cannot convert to " + paramString + " as this period contains months and months vary in length");
}
if (getYears() != 0) {
throw new UnsupportedOperationException("Cannot convert to " + paramString + " as this period contains years and years vary in length");
}
}
public static Period days(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, 0, 0, paramInt, 0, 0, 0, 0 }, localPeriodType);
}
public static Period fieldDifference(ReadablePartial paramReadablePartial1, ReadablePartial paramReadablePartial2)
{
if ((paramReadablePartial1 == null) || (paramReadablePartial2 == null)) {
throw new IllegalArgumentException("ReadablePartial objects must not be null");
}
if (paramReadablePartial1.size() != paramReadablePartial2.size()) {
throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
}
DurationFieldType[] arrayOfDurationFieldType = new DurationFieldType[paramReadablePartial1.size()];
int[] arrayOfInt = new int[paramReadablePartial1.size()];
int i = 0;
int j = paramReadablePartial1.size();
while (i < j)
{
if (paramReadablePartial1.getFieldType(i) != paramReadablePartial2.getFieldType(i)) {
throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
}
arrayOfDurationFieldType[i] = paramReadablePartial1.getFieldType(i).getDurationType();
if ((i > 0) && (arrayOfDurationFieldType[(i - 1)] == arrayOfDurationFieldType[i])) {
throw new IllegalArgumentException("ReadablePartial objects must not have overlapping fields");
}
arrayOfInt[i] = (paramReadablePartial2.getValue(i) - paramReadablePartial1.getValue(i));
i += 1;
}
return new Period(arrayOfInt, PeriodType.forFields(arrayOfDurationFieldType));
}
public static Period hours(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, 0, 0, 0, paramInt, 0, 0, 0 }, localPeriodType);
}
public static Period millis(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, 0, 0, 0, 0, 0, 0, paramInt }, localPeriodType);
}
public static Period minutes(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, 0, 0, 0, 0, paramInt, 0, 0 }, localPeriodType);
}
public static Period months(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, paramInt, 0, 0, 0, 0, 0, 0 }, localPeriodType);
}
@FromString
public static Period parse(String paramString)
{
return parse(paramString, ISOPeriodFormat.standard());
}
public static Period parse(String paramString, PeriodFormatter paramPeriodFormatter)
{
return paramPeriodFormatter.parsePeriod(paramString);
}
public static Period seconds(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, 0, 0, 0, 0, 0, paramInt, 0 }, localPeriodType);
}
public static Period weeks(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { 0, 0, paramInt, 0, 0, 0, 0, 0 }, localPeriodType);
}
public static Period years(int paramInt)
{
PeriodType localPeriodType = PeriodType.standard();
return new Period(new int[] { paramInt, 0, 0, 0, 0, 0, 0, 0, 0 }, localPeriodType);
}
public final int getDays()
{
return getPeriodType().a(this, PeriodType.d);
}
public final int getHours()
{
return getPeriodType().a(this, PeriodType.e);
}
public final int getMillis()
{
return getPeriodType().a(this, PeriodType.h);
}
public final int getMinutes()
{
return getPeriodType().a(this, PeriodType.f);
}
public final int getMonths()
{
return getPeriodType().a(this, PeriodType.b);
}
public final int getSeconds()
{
return getPeriodType().a(this, PeriodType.g);
}
public final int getWeeks()
{
return getPeriodType().a(this, PeriodType.c);
}
public final int getYears()
{
return getPeriodType().a(this, PeriodType.a);
}
public final Period minus(ReadablePeriod paramReadablePeriod)
{
if (paramReadablePeriod == null) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.a, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.d));
getPeriodType().b(PeriodType.b, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.e));
getPeriodType().b(PeriodType.c, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.f));
getPeriodType().b(PeriodType.d, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.g));
getPeriodType().b(PeriodType.e, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.i));
getPeriodType().b(PeriodType.f, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.j));
getPeriodType().b(PeriodType.g, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.k));
getPeriodType().b(PeriodType.h, arrayOfInt, -paramReadablePeriod.get(DurationFieldType.l));
return new Period(arrayOfInt, getPeriodType());
}
public final Period minusDays(int paramInt)
{
return plusDays(-paramInt);
}
public final Period minusHours(int paramInt)
{
return plusHours(-paramInt);
}
public final Period minusMillis(int paramInt)
{
return plusMillis(-paramInt);
}
public final Period minusMinutes(int paramInt)
{
return plusMinutes(-paramInt);
}
public final Period minusMonths(int paramInt)
{
return plusMonths(-paramInt);
}
public final Period minusSeconds(int paramInt)
{
return plusSeconds(-paramInt);
}
public final Period minusWeeks(int paramInt)
{
return plusWeeks(-paramInt);
}
public final Period minusYears(int paramInt)
{
return plusYears(-paramInt);
}
public final Period multipliedBy(int paramInt)
{
if ((this == ZERO) || (paramInt == 1)) {
return this;
}
int[] arrayOfInt = getValues();
int i = 0;
while (i < arrayOfInt.length)
{
arrayOfInt[i] = FieldUtils.safeMultiply(arrayOfInt[i], paramInt);
i += 1;
}
return new Period(arrayOfInt, getPeriodType());
}
public final Period negated()
{
return multipliedBy(-1);
}
public final Period normalizedStandard()
{
return normalizedStandard(PeriodType.standard());
}
public final Period normalizedStandard(PeriodType paramPeriodType)
{
long l1 = getMillis();
long l2 = getSeconds();
long l3 = getMinutes();
long l4 = getHours();
long l5 = getDays();
Period localPeriod = new Period(getWeeks() * 604800000L + (l1 + l2 * 1000L + l3 * 60000L + l4 * 3600000L + l5 * 86400000L), DateTimeUtils.getPeriodType(paramPeriodType), ISOChronology.getInstanceUTC());
int j = getYears();
int i = getMonths();
Object localObject;
if (j == 0)
{
localObject = localPeriod;
if (i == 0) {}
}
else
{
j = FieldUtils.safeAdd(j, i / 12);
i %= 12;
paramPeriodType = localPeriod;
if (j != 0) {
paramPeriodType = localPeriod.withYears(j);
}
localObject = paramPeriodType;
if (i != 0) {
localObject = paramPeriodType.withMonths(i);
}
}
return (Period)localObject;
}
public final Period plus(ReadablePeriod paramReadablePeriod)
{
if (paramReadablePeriod == null) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.a, arrayOfInt, paramReadablePeriod.get(DurationFieldType.d));
getPeriodType().b(PeriodType.b, arrayOfInt, paramReadablePeriod.get(DurationFieldType.e));
getPeriodType().b(PeriodType.c, arrayOfInt, paramReadablePeriod.get(DurationFieldType.f));
getPeriodType().b(PeriodType.d, arrayOfInt, paramReadablePeriod.get(DurationFieldType.g));
getPeriodType().b(PeriodType.e, arrayOfInt, paramReadablePeriod.get(DurationFieldType.i));
getPeriodType().b(PeriodType.f, arrayOfInt, paramReadablePeriod.get(DurationFieldType.j));
getPeriodType().b(PeriodType.g, arrayOfInt, paramReadablePeriod.get(DurationFieldType.k));
getPeriodType().b(PeriodType.h, arrayOfInt, paramReadablePeriod.get(DurationFieldType.l));
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusDays(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.d, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusHours(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.e, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusMillis(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.h, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusMinutes(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.f, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusMonths(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.b, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusSeconds(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.g, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusWeeks(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.c, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period plusYears(int paramInt)
{
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
getPeriodType().b(PeriodType.a, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period toPeriod()
{
return this;
}
public final Days toStandardDays()
{
a("Days");
return Days.days(FieldUtils.safeToInt(FieldUtils.safeAdd(FieldUtils.safeAdd((getMillis() + getSeconds() * 1000L + getMinutes() * 60000L + getHours() * 3600000L) / 86400000L, getDays()), getWeeks() * 7L)));
}
public final Duration toStandardDuration()
{
a("Duration");
return new Duration(getMillis() + getSeconds() * 1000L + getMinutes() * 60000L + getHours() * 3600000L + getDays() * 86400000L + getWeeks() * 604800000L);
}
public final Hours toStandardHours()
{
a("Hours");
return Hours.hours(FieldUtils.safeToInt(FieldUtils.safeAdd(FieldUtils.safeAdd(FieldUtils.safeAdd((getMillis() + getSeconds() * 1000L + getMinutes() * 60000L) / 3600000L, getHours()), getDays() * 24L), getWeeks() * 168L)));
}
public final Minutes toStandardMinutes()
{
a("Minutes");
return Minutes.minutes(FieldUtils.safeToInt(FieldUtils.safeAdd(FieldUtils.safeAdd(FieldUtils.safeAdd(FieldUtils.safeAdd((getMillis() + getSeconds() * 1000L) / 60000L, getMinutes()), getHours() * 60L), getDays() * 1440L), getWeeks() * 10080L)));
}
public final Seconds toStandardSeconds()
{
a("Seconds");
return Seconds.seconds(FieldUtils.safeToInt(FieldUtils.safeAdd(FieldUtils.safeAdd(FieldUtils.safeAdd(FieldUtils.safeAdd(FieldUtils.safeAdd(getMillis() / 1000, getSeconds()), getMinutes() * 60L), getHours() * 3600L), getDays() * 86400L), getWeeks() * 604800L)));
}
public final Weeks toStandardWeeks()
{
a("Weeks");
long l1 = getMillis();
long l2 = getSeconds();
long l3 = getMinutes();
long l4 = getHours();
long l5 = getDays();
long l6 = getWeeks();
return Weeks.weeks(FieldUtils.safeToInt((l1 + l2 * 1000L + l3 * 60000L + l4 * 3600000L + l5 * 86400000L) / 604800000L + l6));
}
public final Period withDays(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.d, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withField(DurationFieldType paramDurationFieldType, int paramInt)
{
if (paramDurationFieldType == null) {
throw new IllegalArgumentException("Field must not be null");
}
int[] arrayOfInt = getValues();
super.setFieldInto(arrayOfInt, paramDurationFieldType, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withFieldAdded(DurationFieldType paramDurationFieldType, int paramInt)
{
if (paramDurationFieldType == null) {
throw new IllegalArgumentException("Field must not be null");
}
if (paramInt == 0) {
return this;
}
int[] arrayOfInt = getValues();
super.addFieldInto(arrayOfInt, paramDurationFieldType, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withFields(ReadablePeriod paramReadablePeriod)
{
if (paramReadablePeriod == null) {
return this;
}
return new Period(super.mergePeriodInto(getValues(), paramReadablePeriod), getPeriodType());
}
public final Period withHours(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.e, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withMillis(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.h, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withMinutes(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.f, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withMonths(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.b, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withPeriodType(PeriodType paramPeriodType)
{
paramPeriodType = DateTimeUtils.getPeriodType(paramPeriodType);
if (paramPeriodType.equals(getPeriodType())) {
return this;
}
return new Period(this, paramPeriodType);
}
public final Period withSeconds(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.g, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withWeeks(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.c, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
public final Period withYears(int paramInt)
{
int[] arrayOfInt = getValues();
getPeriodType().a(PeriodType.a, arrayOfInt, paramInt);
return new Period(arrayOfInt, getPeriodType());
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/org/joda/time/Period.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/