MutableDateTime.java 17.5 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 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
package org.joda.time;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Locale;
import org.joda.convert.FromString;
import org.joda.convert.ToString;
import org.joda.time.base.BaseDateTime;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.field.AbstractReadableInstantFieldProperty;
import org.joda.time.field.FieldUtils;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

public class MutableDateTime
  extends BaseDateTime
  implements Serializable, Cloneable, ReadWritableDateTime
{
  public static final int ROUND_CEILING = 2;
  public static final int ROUND_FLOOR = 1;
  public static final int ROUND_HALF_CEILING = 4;
  public static final int ROUND_HALF_EVEN = 5;
  public static final int ROUND_HALF_FLOOR = 3;
  public static final int ROUND_NONE = 0;
  private static final long serialVersionUID = 2852608688135209575L;
  private DateTimeField a;
  private int b;
  
  public MutableDateTime() {}
  
  public MutableDateTime(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7)
  {
    super(paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7);
  }
  
  public MutableDateTime(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, Chronology paramChronology)
  {
    super(paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7, paramChronology);
  }
  
  public MutableDateTime(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, DateTimeZone paramDateTimeZone)
  {
    super(paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7, paramDateTimeZone);
  }
  
  public MutableDateTime(long paramLong)
  {
    super(paramLong);
  }
  
  public MutableDateTime(long paramLong, Chronology paramChronology)
  {
    super(paramLong, paramChronology);
  }
  
  public MutableDateTime(long paramLong, DateTimeZone paramDateTimeZone)
  {
    super(paramLong, paramDateTimeZone);
  }
  
  public MutableDateTime(Object paramObject)
  {
    super(paramObject, null);
  }
  
  public MutableDateTime(Object paramObject, Chronology paramChronology)
  {
    super(paramObject, DateTimeUtils.getChronology(paramChronology));
  }
  
  public MutableDateTime(Object paramObject, DateTimeZone paramDateTimeZone)
  {
    super(paramObject, paramDateTimeZone);
  }
  
  public MutableDateTime(Chronology paramChronology)
  {
    super(paramChronology);
  }
  
  public MutableDateTime(DateTimeZone paramDateTimeZone)
  {
    super(paramDateTimeZone);
  }
  
  public static MutableDateTime now()
  {
    return new MutableDateTime();
  }
  
  public static MutableDateTime now(Chronology paramChronology)
  {
    if (paramChronology == null) {
      throw new NullPointerException("Chronology must not be null");
    }
    return new MutableDateTime(paramChronology);
  }
  
  public static MutableDateTime now(DateTimeZone paramDateTimeZone)
  {
    if (paramDateTimeZone == null) {
      throw new NullPointerException("Zone must not be null");
    }
    return new MutableDateTime(paramDateTimeZone);
  }
  
  @FromString
  public static MutableDateTime parse(String paramString)
  {
    return parse(paramString, ISODateTimeFormat.dateTimeParser().withOffsetParsed());
  }
  
  public static MutableDateTime parse(String paramString, DateTimeFormatter paramDateTimeFormatter)
  {
    return paramDateTimeFormatter.parseDateTime(paramString).toMutableDateTime();
  }
  
  public void add(long paramLong)
  {
    setMillis(FieldUtils.safeAdd(getMillis(), paramLong));
  }
  
  public void add(DurationFieldType paramDurationFieldType, int paramInt)
  {
    if (paramDurationFieldType == null) {
      throw new IllegalArgumentException("Field must not be null");
    }
    setMillis(paramDurationFieldType.getField(getChronology()).add(getMillis(), paramInt));
  }
  
  public void add(ReadableDuration paramReadableDuration)
  {
    add(paramReadableDuration, 1);
  }
  
  public void add(ReadableDuration paramReadableDuration, int paramInt)
  {
    if (paramReadableDuration != null) {
      add(FieldUtils.safeMultiply(paramReadableDuration.getMillis(), paramInt));
    }
  }
  
  public void add(ReadablePeriod paramReadablePeriod)
  {
    add(paramReadablePeriod, 1);
  }
  
  public void add(ReadablePeriod paramReadablePeriod, int paramInt)
  {
    if (paramReadablePeriod != null) {
      setMillis(getChronology().add(paramReadablePeriod, getMillis(), paramInt));
    }
  }
  
  public void addDays(int paramInt)
  {
    setMillis(getChronology().days().add(getMillis(), paramInt));
  }
  
  public void addHours(int paramInt)
  {
    setMillis(getChronology().hours().add(getMillis(), paramInt));
  }
  
  public void addMillis(int paramInt)
  {
    setMillis(getChronology().millis().add(getMillis(), paramInt));
  }
  
  public void addMinutes(int paramInt)
  {
    setMillis(getChronology().minutes().add(getMillis(), paramInt));
  }
  
  public void addMonths(int paramInt)
  {
    setMillis(getChronology().months().add(getMillis(), paramInt));
  }
  
  public void addSeconds(int paramInt)
  {
    setMillis(getChronology().seconds().add(getMillis(), paramInt));
  }
  
  public void addWeeks(int paramInt)
  {
    setMillis(getChronology().weeks().add(getMillis(), paramInt));
  }
  
  public void addWeekyears(int paramInt)
  {
    setMillis(getChronology().weekyears().add(getMillis(), paramInt));
  }
  
  public void addYears(int paramInt)
  {
    setMillis(getChronology().years().add(getMillis(), paramInt));
  }
  
  public Property centuryOfEra()
  {
    return new Property(this, getChronology().centuryOfEra());
  }
  
  public Object clone()
  {
    try
    {
      Object localObject = super.clone();
      return localObject;
    }
    catch (CloneNotSupportedException localCloneNotSupportedException)
    {
      throw new InternalError("Clone error");
    }
  }
  
  public MutableDateTime copy()
  {
    return (MutableDateTime)clone();
  }
  
  public Property dayOfMonth()
  {
    return new Property(this, getChronology().dayOfMonth());
  }
  
  public Property dayOfWeek()
  {
    return new Property(this, getChronology().dayOfWeek());
  }
  
  public Property dayOfYear()
  {
    return new Property(this, getChronology().dayOfYear());
  }
  
  public Property era()
  {
    return new Property(this, getChronology().era());
  }
  
  public DateTimeField getRoundingField()
  {
    return this.a;
  }
  
  public int getRoundingMode()
  {
    return this.b;
  }
  
  public Property hourOfDay()
  {
    return new Property(this, getChronology().hourOfDay());
  }
  
  public Property millisOfDay()
  {
    return new Property(this, getChronology().millisOfDay());
  }
  
  public Property millisOfSecond()
  {
    return new Property(this, getChronology().millisOfSecond());
  }
  
  public Property minuteOfDay()
  {
    return new Property(this, getChronology().minuteOfDay());
  }
  
  public Property minuteOfHour()
  {
    return new Property(this, getChronology().minuteOfHour());
  }
  
  public Property monthOfYear()
  {
    return new Property(this, getChronology().monthOfYear());
  }
  
  public Property property(DateTimeFieldType paramDateTimeFieldType)
  {
    if (paramDateTimeFieldType == null) {
      throw new IllegalArgumentException("The DateTimeFieldType must not be null");
    }
    DateTimeField localDateTimeField = paramDateTimeFieldType.getField(getChronology());
    if (!localDateTimeField.isSupported()) {
      throw new IllegalArgumentException("Field '" + paramDateTimeFieldType + "' is not supported");
    }
    return new Property(this, localDateTimeField);
  }
  
  public Property secondOfDay()
  {
    return new Property(this, getChronology().secondOfDay());
  }
  
  public Property secondOfMinute()
  {
    return new Property(this, getChronology().secondOfMinute());
  }
  
  public void set(DateTimeFieldType paramDateTimeFieldType, int paramInt)
  {
    if (paramDateTimeFieldType == null) {
      throw new IllegalArgumentException("Field must not be null");
    }
    setMillis(paramDateTimeFieldType.getField(getChronology()).set(getMillis(), paramInt));
  }
  
  public void setChronology(Chronology paramChronology)
  {
    super.setChronology(paramChronology);
  }
  
  public void setDate(int paramInt1, int paramInt2, int paramInt3)
  {
    setDate(getChronology().getDateTimeMillis(paramInt1, paramInt2, paramInt3, 0));
  }
  
  public void setDate(long paramLong)
  {
    setMillis(getChronology().millisOfDay().set(paramLong, getMillisOfDay()));
  }
  
  public void setDate(ReadableInstant paramReadableInstant)
  {
    long l2 = DateTimeUtils.getInstantMillis(paramReadableInstant);
    long l1 = l2;
    if ((paramReadableInstant instanceof ReadableDateTime))
    {
      paramReadableInstant = DateTimeUtils.getChronology(((ReadableDateTime)paramReadableInstant).getChronology()).getZone();
      l1 = l2;
      if (paramReadableInstant != null) {
        l1 = paramReadableInstant.getMillisKeepLocal(getZone(), l2);
      }
    }
    setDate(l1);
  }
  
  public void setDateTime(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7)
  {
    setMillis(getChronology().getDateTimeMillis(paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramInt7));
  }
  
  public void setDayOfMonth(int paramInt)
  {
    setMillis(getChronology().dayOfMonth().set(getMillis(), paramInt));
  }
  
  public void setDayOfWeek(int paramInt)
  {
    setMillis(getChronology().dayOfWeek().set(getMillis(), paramInt));
  }
  
  public void setDayOfYear(int paramInt)
  {
    setMillis(getChronology().dayOfYear().set(getMillis(), paramInt));
  }
  
  public void setHourOfDay(int paramInt)
  {
    setMillis(getChronology().hourOfDay().set(getMillis(), paramInt));
  }
  
  public void setMillis(long paramLong)
  {
    long l = paramLong;
    switch (this.b)
    {
    default: 
      l = paramLong;
    }
    for (;;)
    {
      super.setMillis(l);
      return;
      l = this.a.roundFloor(paramLong);
      continue;
      l = this.a.roundCeiling(paramLong);
      continue;
      l = this.a.roundHalfFloor(paramLong);
      continue;
      l = this.a.roundHalfCeiling(paramLong);
      continue;
      l = this.a.roundHalfEven(paramLong);
    }
  }
  
  public void setMillis(ReadableInstant paramReadableInstant)
  {
    setMillis(DateTimeUtils.getInstantMillis(paramReadableInstant));
  }
  
  public void setMillisOfDay(int paramInt)
  {
    setMillis(getChronology().millisOfDay().set(getMillis(), paramInt));
  }
  
  public void setMillisOfSecond(int paramInt)
  {
    setMillis(getChronology().millisOfSecond().set(getMillis(), paramInt));
  }
  
  public void setMinuteOfDay(int paramInt)
  {
    setMillis(getChronology().minuteOfDay().set(getMillis(), paramInt));
  }
  
  public void setMinuteOfHour(int paramInt)
  {
    setMillis(getChronology().minuteOfHour().set(getMillis(), paramInt));
  }
  
  public void setMonthOfYear(int paramInt)
  {
    setMillis(getChronology().monthOfYear().set(getMillis(), paramInt));
  }
  
  public void setRounding(DateTimeField paramDateTimeField)
  {
    setRounding(paramDateTimeField, 1);
  }
  
  public void setRounding(DateTimeField paramDateTimeField, int paramInt)
  {
    if ((paramDateTimeField != null) && ((paramInt < 0) || (paramInt > 5))) {
      throw new IllegalArgumentException("Illegal rounding mode: " + paramInt);
    }
    if (paramInt == 0) {}
    for (DateTimeField localDateTimeField = null;; localDateTimeField = paramDateTimeField)
    {
      this.a = localDateTimeField;
      if (paramDateTimeField == null) {
        paramInt = 0;
      }
      this.b = paramInt;
      setMillis(getMillis());
      return;
    }
  }
  
  public void setSecondOfDay(int paramInt)
  {
    setMillis(getChronology().secondOfDay().set(getMillis(), paramInt));
  }
  
  public void setSecondOfMinute(int paramInt)
  {
    setMillis(getChronology().secondOfMinute().set(getMillis(), paramInt));
  }
  
  public void setTime(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    setMillis(getChronology().getDateTimeMillis(getMillis(), paramInt1, paramInt2, paramInt3, paramInt4));
  }
  
  public void setTime(long paramLong)
  {
    int i = ISOChronology.getInstanceUTC().millisOfDay().get(paramLong);
    setMillis(getChronology().millisOfDay().set(getMillis(), i));
  }
  
  public void setTime(ReadableInstant paramReadableInstant)
  {
    long l2 = DateTimeUtils.getInstantMillis(paramReadableInstant);
    paramReadableInstant = DateTimeUtils.getInstantChronology(paramReadableInstant).getZone();
    long l1 = l2;
    if (paramReadableInstant != null) {
      l1 = paramReadableInstant.getMillisKeepLocal(DateTimeZone.UTC, l2);
    }
    setTime(l1);
  }
  
  public void setWeekOfWeekyear(int paramInt)
  {
    setMillis(getChronology().weekOfWeekyear().set(getMillis(), paramInt));
  }
  
  public void setWeekyear(int paramInt)
  {
    setMillis(getChronology().weekyear().set(getMillis(), paramInt));
  }
  
  public void setYear(int paramInt)
  {
    setMillis(getChronology().year().set(getMillis(), paramInt));
  }
  
  public void setZone(DateTimeZone paramDateTimeZone)
  {
    paramDateTimeZone = DateTimeUtils.getZone(paramDateTimeZone);
    Chronology localChronology = getChronology();
    if (localChronology.getZone() != paramDateTimeZone) {
      setChronology(localChronology.withZone(paramDateTimeZone));
    }
  }
  
  public void setZoneRetainFields(DateTimeZone paramDateTimeZone)
  {
    paramDateTimeZone = DateTimeUtils.getZone(paramDateTimeZone);
    DateTimeZone localDateTimeZone = DateTimeUtils.getZone(getZone());
    if (paramDateTimeZone == localDateTimeZone) {
      return;
    }
    long l = localDateTimeZone.getMillisKeepLocal(paramDateTimeZone, getMillis());
    setChronology(getChronology().withZone(paramDateTimeZone));
    setMillis(l);
  }
  
  @ToString
  public String toString()
  {
    return ISODateTimeFormat.dateTime().print(this);
  }
  
  public Property weekOfWeekyear()
  {
    return new Property(this, getChronology().weekOfWeekyear());
  }
  
  public Property weekyear()
  {
    return new Property(this, getChronology().weekyear());
  }
  
  public Property year()
  {
    return new Property(this, getChronology().year());
  }
  
  public Property yearOfCentury()
  {
    return new Property(this, getChronology().yearOfCentury());
  }
  
  public Property yearOfEra()
  {
    return new Property(this, getChronology().yearOfEra());
  }
  
  public static final class Property
    extends AbstractReadableInstantFieldProperty
  {
    private static final long serialVersionUID = -4481126543819298617L;
    private MutableDateTime a;
    private DateTimeField b;
    
    Property(MutableDateTime paramMutableDateTime, DateTimeField paramDateTimeField)
    {
      this.a = paramMutableDateTime;
      this.b = paramDateTimeField;
    }
    
    private void readObject(ObjectInputStream paramObjectInputStream)
      throws IOException, ClassNotFoundException
    {
      this.a = ((MutableDateTime)paramObjectInputStream.readObject());
      this.b = ((DateTimeFieldType)paramObjectInputStream.readObject()).getField(this.a.getChronology());
    }
    
    private void writeObject(ObjectOutputStream paramObjectOutputStream)
      throws IOException
    {
      paramObjectOutputStream.writeObject(this.a);
      paramObjectOutputStream.writeObject(this.b.getType());
    }
    
    public final MutableDateTime add(int paramInt)
    {
      this.a.setMillis(getField().add(this.a.getMillis(), paramInt));
      return this.a;
    }
    
    public final MutableDateTime add(long paramLong)
    {
      this.a.setMillis(getField().add(this.a.getMillis(), paramLong));
      return this.a;
    }
    
    public final MutableDateTime addWrapField(int paramInt)
    {
      this.a.setMillis(getField().addWrapField(this.a.getMillis(), paramInt));
      return this.a;
    }
    
    protected final Chronology getChronology()
    {
      return this.a.getChronology();
    }
    
    public final DateTimeField getField()
    {
      return this.b;
    }
    
    protected final long getMillis()
    {
      return this.a.getMillis();
    }
    
    public final MutableDateTime getMutableDateTime()
    {
      return this.a;
    }
    
    public final MutableDateTime roundCeiling()
    {
      this.a.setMillis(getField().roundCeiling(this.a.getMillis()));
      return this.a;
    }
    
    public final MutableDateTime roundFloor()
    {
      this.a.setMillis(getField().roundFloor(this.a.getMillis()));
      return this.a;
    }
    
    public final MutableDateTime roundHalfCeiling()
    {
      this.a.setMillis(getField().roundHalfCeiling(this.a.getMillis()));
      return this.a;
    }
    
    public final MutableDateTime roundHalfEven()
    {
      this.a.setMillis(getField().roundHalfEven(this.a.getMillis()));
      return this.a;
    }
    
    public final MutableDateTime roundHalfFloor()
    {
      this.a.setMillis(getField().roundHalfFloor(this.a.getMillis()));
      return this.a;
    }
    
    public final MutableDateTime set(int paramInt)
    {
      this.a.setMillis(getField().set(this.a.getMillis(), paramInt));
      return this.a;
    }
    
    public final MutableDateTime set(String paramString)
    {
      set(paramString, null);
      return this.a;
    }
    
    public final MutableDateTime set(String paramString, Locale paramLocale)
    {
      this.a.setMillis(getField().set(this.a.getMillis(), paramString, paramLocale));
      return this.a;
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/org/joda/time/MutableDateTime.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */