public void testConstructor_RI_RI_chronoStart() throws Throwable {
   DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0, GJChronology.getInstance());
   DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
   Interval test = new Interval(dt1, dt2);
   assertEquals(dt1.getMillis(), test.getStartMillis());
   assertEquals(dt2.getMillis(), test.getEndMillis());
   assertEquals(GJChronology.getInstance(), test.getChronology());
 }
 public void testSetInto_Object_Chronology2() throws Exception {
   MutableInterval m = new MutableInterval(1000L, 2000L, GJChronology.getInstance());
   NullConverter.INSTANCE.setInto(m, null, CopticChronology.getInstance());
   assertEquals(TEST_TIME_NOW, m.getStartMillis());
   assertEquals(TEST_TIME_NOW, m.getEndMillis());
   assertEquals(CopticChronology.getInstance(), m.getChronology());
 }
  public void execute(JobExecutionContext context) throws JobExecutionException {
    EventWindowData.loadInitialData();

    DateTimeZone zone = DateTimeZone.forID("America/New_York");
    Chronology gregorianJuian = GJChronology.getInstance(zone);

    List<String> serverIds = new ArrayList<>();

    for (ServerID servId : ServerID.values()) {
      serverIds.add(servId.getUid() + "");
    }

    // System.out.println("Starting LowPriority Thread retrieve "+this.toString()+" at "+new
    // DateTime(gregorianJuian));

    for (GolemEvent eventId : GolemEvent.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    for (DredgeEvent eventId : DredgeEvent.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    for (HarathiChestEvent eventId : HarathiChestEvent.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    for (FoulBearEvent eventId : FoulBearEvent.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    for (HydraQueenEvent eventId : HydraQueenEvent.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    for (FireShamanEnum eventId : FireShamanEnum.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    for (KarkaEvent eventId : KarkaEvent.values()) {
      queryEvent(gregorianJuian, serverIds, eventId.uid(), lowPriorityEventData);
    }

    // System.out.println("Ended LowPriority Thread retrieve "+this.toString()+" at "+new
    // DateTime(gregorianJuian));

    GolemEvent.formatGolemString(lowPriorityEventData);
    DredgeEvent.formatDredgeString(lowPriorityEventData);
    FoulBearEvent.formatOgreString(lowPriorityEventData);
    HarathiChestEvent.formatHarathiString(lowPriorityEventData);
    HydraQueenEvent.formatHydraString(lowPriorityEventData);
    FireShamanEnum.formatShamanString(lowPriorityEventData);
    KarkaEvent.formatKarkaString(lowPriorityEventData);

    // System.out.println("Ended LowPriority Thread formating "+this.toString()+" at "+new
    // DateTime(gregorianJuian));
  }
  public void testEqualsHashCode() {
    MutableInterval test1 = new MutableInterval(TEST_TIME1, TEST_TIME2);
    MutableInterval test2 = new MutableInterval(TEST_TIME1, TEST_TIME2);
    assertEquals(true, test1.equals(test2));
    assertEquals(true, test2.equals(test1));
    assertEquals(true, test1.equals(test1));
    assertEquals(true, test2.equals(test2));
    assertEquals(true, test1.hashCode() == test2.hashCode());
    assertEquals(true, test1.hashCode() == test1.hashCode());
    assertEquals(true, test2.hashCode() == test2.hashCode());

    MutableInterval test3 = new MutableInterval(TEST_TIME_NOW, TEST_TIME2);
    assertEquals(false, test1.equals(test3));
    assertEquals(false, test2.equals(test3));
    assertEquals(false, test3.equals(test1));
    assertEquals(false, test3.equals(test2));
    assertEquals(false, test1.hashCode() == test3.hashCode());
    assertEquals(false, test2.hashCode() == test3.hashCode());

    MutableInterval test4 = new MutableInterval(TEST_TIME1, TEST_TIME2, GJChronology.getInstance());
    assertEquals(true, test4.equals(test4));
    assertEquals(false, test1.equals(test4));
    assertEquals(false, test2.equals(test4));
    assertEquals(false, test4.equals(test1));
    assertEquals(false, test4.equals(test2));
    assertEquals(false, test1.hashCode() == test4.hashCode());
    assertEquals(false, test2.hashCode() == test4.hashCode());

    MutableInterval test5 = new MutableInterval(TEST_TIME1, TEST_TIME2);
    assertEquals(true, test1.equals(test5));
    assertEquals(true, test2.equals(test5));
    assertEquals(false, test3.equals(test5));
    assertEquals(true, test5.equals(test1));
    assertEquals(true, test5.equals(test2));
    assertEquals(false, test5.equals(test3));
    assertEquals(true, test1.hashCode() == test5.hashCode());
    assertEquals(true, test2.hashCode() == test5.hashCode());
    assertEquals(false, test3.hashCode() == test5.hashCode());

    assertEquals(false, test1.equals("Hello"));
    assertEquals(true, test1.equals(new MockInterval()));
    assertEquals(false, test1.equals(new DateTime(TEST_TIME1)));
  }
示例#5
0
  public static void main(String[] args) {

    Chronology chronology = GJChronology.getInstance();

    LocalDate start = new LocalDate(2013, 5, 31, chronology);
    LocalDate expectedEnd = new LocalDate(-1, 5, 31, chronology); // 1 BC
    System.out.println(start.minusYears(2012));
    System.out.println(start.minusYears(2013));
    System.out.println(expectedEnd);
    System.out.println("-----");
    System.out.println(start.plus(Period.years(-2013)));
    System.out.println(expectedEnd);

    //        DateTime dateTimeBefore = new DateTime(2012, 10, 28, 2, 59, 0, 0,
    // DateTimeZone.forID("+02:00"));
    //        System.out.println(dateTimeBefore);
    //        DateTime dateTimeAfter = dateTimeBefore.withSecondOfMinute(0);
    //        System.out.println(dateTimeAfter);
    //        System.out.println(dateTimeBefore.equals(dateTimeAfter));
    //
    //        DateTime dateTimeBefore2 = new DateTime(2012, 10, 28, 2, 59, 0, 0,
    // DateTimeZone.forID("Europe/Berlin"));
    //        System.out.println(dateTimeBefore2);
    //        DateTime dateTimeAfter2 = dateTimeBefore2.withSecondOfMinute(0);
    //        System.out.println(dateTimeAfter2);
    //        System.out.println(dateTimeBefore2.equals(dateTimeAfter2));
    //
    //        DateTime dateTimeBefore3 = new DateTime(2012, 10, 28, 1, 59, 0, 0,
    // DateTimeZone.forID("Europe/Berlin"));
    //        dateTimeBefore3 = dateTimeBefore3.plusMinutes(60); // 2:59 +02:00 with Europe/Berlin
    //        System.out.println(dateTimeBefore3);
    //        DateTime dateTimeAfter3 = dateTimeBefore2.withSecondOfMinute(0);
    //        System.out.println(dateTimeAfter3);
    //        // DateTimeZone changed from +02:00 to +01:00
    //        System.out.println(dateTimeBefore3.equals(dateTimeAfter3));

    //        final DateTime start = new LocalDateTime(2012, 11, 4, 1,
    // 30).toDateTime(DateTimeZone.forID("America/New_York"));
    //        final DateTime end = new LocalDateTime(2012, 11, 4, 2,
    // 0).toDateTime(DateTimeZone.forID("America/New_York"));
    //        System.out.println(start);
    //        System.out.println(end);
    //
    //        final MutableInterval interval = new MutableInterval(start, end);
    //        System.out.println(interval);
    //        System.out.println(new Period(interval));
    //        System.out.println(Hours.hoursIn(interval));
    //        System.out.println(Hours.hoursIn(interval).getHours());
    //
    //        // Period is correctly PT1H30, 1 == 1
    //        Assert.assertEquals(interval.toPeriod().getHours(),
    // Hours.hoursIn(interval).getHours());
    //
    //        interval.setStart(interval.getStart().plusHours(1));
    //        System.out.println("-----");
    //        System.out.println(interval);
    //        System.out.println(new Period(interval));
    //        System.out.println(Hours.hoursIn(interval));
    //        System.out.println(Hours.hoursIn(interval).getHours());
    //        // Period is incorrectly PT1H30, 1 == 0
    //        Assert.assertEquals(Hours.hoursIn(interval).getHours(),
    // interval.toPeriod().getHours());

    //        DateTimeFormat.forPattern("dd.MM.yyyy").parseDateTime("00.10.2010");

    //        DateTime dateTime = new DateTime("2010-10-10T04:00:00",
    //        DateTimeZone.forID("America/Caracas"));
    //        // time zone is -04:30 -- UTC date time is 2010-10-09T23:30
    //
    //        System.out.println(dateTime + " " + dateTime.getChronology());
    //        MutableDateTime mutableDateTime = dateTime.toMutableDateTime();
    //        mutableDateTime.setDate(dateTime); // is essentially a no-op
    //        System.out.println(mutableDateTime + " " + mutableDateTime.getChronology());

    //        Expected is: 2010-10-10T04:00:00.000-04:30
    //        Actual result is: 2010-10-09T04:00:00.000-04:30

    //      DateTime dt = new DateTime(1, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
    //      dt = dt.minusDays(1);
    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
    //
    //      dt = new DateTime(1, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
    //      dt = dt.minusDays(1);
    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
    //
    //      dt = new DateTime(100000, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));
    //
    //      dt = new DateTime(-100000, 1, 1, 0, 0, 0, GregorianChronology.getInstanceUTC());
    //      System.out.println(dt + " " + dt.toString("yyyy YYYY GG"));

    //      DateTime birth = new DateTime(2012, 03, 31, 02, 28, 0, 0).minus(Years.years(27));
    //      DateTime now = new DateTime(2012, 03, 31, 02, 28, 33, 0);
    //      System.out.println(birth);
    //      System.out.println(now);
    //      System.out.println(new Period(birth, now));

    //      // From the first test
    //      // Comment out (in) the following call in order to make the test pass (fail).
    //      DateTimeZone p1 = DateTimeZone.forID("Europe/Paris");
    //      System.out.println(p1 + " " + System.identityHashCode(p1));
    //      DateTimeZone.setDefault(p1);
    //      new DateMidnight(2004, 6, 9);
    //      // From the first test
    //
    //      // From the second test
    //      DateTimeZone.setProvider(null);
    //      // From the second test
    //
    //      // From the third test
    //      DateTimeZone p2 = DateTimeZone.forID("Europe/Paris");
    //      System.out.println(p2 + " " + System.identityHashCode(p2));
    //      DateTimeZone.setDefault(p2);
    //
    //      DateTime test = new DateTime(0);
    //      DateTime result = test.withZoneRetainFields(p2);
    //      if (test != result) {
    //        throw new IllegalArgumentException();
    //      }
  }