Java源码示例:org.threeten.bp.Month

示例1
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_basic);
  ButterKnife.bind(this);

  widget.setOnDateChangedListener(this);
  widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);

  final LocalDate instance = LocalDate.now();
  widget.setSelectedDate(instance);

  final LocalDate min = LocalDate.of(instance.getYear(), Month.JANUARY, 1);
  final LocalDate max = LocalDate.of(instance.getYear(), Month.DECEMBER, 31);

  widget.state().edit().setMinimumDate(min).setMaximumDate(max).commit();

  widget.addDecorators(
      new MySelectorDecorator(this),
      new HighlightWeekendsDecorator(),
      oneDayDecorator
  );

  new ApiSimulator().executeOnExecutor(Executors.newSingleThreadExecutor());
}
 
示例2
@Override protected void onCreate(final Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_basic);
  ButterKnife.bind(this);

  // Add a decorator to disable prime numbered days
  widget.addDecorator(new PrimeDayDisableDecorator());
  // Add a second decorator that explicitly enables days <= 10. This will work because
  // decorators are applied in order, and the system allows re-enabling
  widget.addDecorator(new EnableOneToTenDecorator());

  final LocalDate calendar = LocalDate.now();
  widget.setSelectedDate(calendar);

  final LocalDate min = LocalDate.of(calendar.getYear(), Month.JANUARY, 1);
  final LocalDate max = LocalDate.of(calendar.getYear() + 1, Month.OCTOBER, 31);

  widget.state().edit()
      .setMinimumDate(min)
      .setMaximumDate(max)
      .commit();
}
 
示例3
@Override protected void onCreate(final Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_basic_modes);
  ButterKnife.bind(this);

  widget.setOnDateChangedListener(this);
  widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);

  final LocalDate instance = LocalDate.now();
  widget.setSelectedDate(instance);

  final LocalDate min = LocalDate.of(instance.getYear(), Month.JANUARY, 1);
  final LocalDate max = LocalDate.of(instance.getYear(), Month.DECEMBER, 31);

  widget.state().edit().setMinimumDate(min).setMaximumDate(max).commit();

  widget.addDecorators(
      new MySelectorDecorator(this),
      new HighlightWeekendsDecorator(),
      oneDayDecorator
  );
}
 
示例4
/**
 * Reads the state from the stream.
 *
 * @param in  the input stream, not null
 * @return the created object, not null
 * @throws IOException if an error occurs
 */
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
    int data = in.readInt();
    Month month = Month.of(data >>> 28);
    int dom = ((data & (63 << 22)) >>> 22) - 32;
    int dowByte = (data & (7 << 19)) >>> 19;
    DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
    int timeByte = (data & (31 << 14)) >>> 14;
    TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
    int stdByte = (data & (255 << 4)) >>> 4;
    int beforeByte = (data & (3 << 2)) >>> 2;
    int afterByte = (data & 3);
    int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600);
    ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
    ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
    ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
    // only bit of validation that we need to copy from public of() method
    if (dom < -28 || dom > 31 || dom == 0) {
        throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
    }
    LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY));
    int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY);
    return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after);
}
 
示例5
public void test_London_getTransitionRules() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
    assertEquals(rules.size(), 2);

    ZoneOffsetTransitionRule in = rules.get(0);
    assertEquals(in.getMonth(), Month.MARCH);
    assertEquals(in.getDayOfMonthIndicator(), 25);  // optimized from -1
    assertEquals(in.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(in.getLocalTime(), LocalTime.of(1, 0));
    assertEquals(in.getTimeDefinition(), TimeDefinition.UTC);
    assertEquals(in.getStandardOffset(), OFFSET_ZERO);
    assertEquals(in.getOffsetBefore(), OFFSET_ZERO);
    assertEquals(in.getOffsetAfter(), OFFSET_PONE);

    ZoneOffsetTransitionRule out = rules.get(1);
    assertEquals(out.getMonth(), Month.OCTOBER);
    assertEquals(out.getDayOfMonthIndicator(), 25);  // optimized from -1
    assertEquals(out.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(out.getLocalTime(), LocalTime.of(1, 0));
    assertEquals(out.getTimeDefinition(), TimeDefinition.UTC);
    assertEquals(out.getStandardOffset(), OFFSET_ZERO);
    assertEquals(out.getOffsetBefore(), OFFSET_PONE);
    assertEquals(out.getOffsetAfter(), OFFSET_ZERO);
}
 
示例6
public void test_Dublin_getStandardOffset() {
    ZoneRules test = europeDublin();
    ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
    while (zdt.getYear() < 2010) {
        Instant instant = zdt.toInstant();
        if (zdt.getYear() < 1881) {
            assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutes(0, -25));
        } else if (zdt.getYear() >= 1881 && zdt.getYear() < 1917) {
            assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, -25, -21));
        } else if (zdt.getYear() >= 1917 && zdt.getYear() < 1969) {
            assertEquals(test.getStandardOffset(instant), OFFSET_ZERO, zdt.toString());
        } else if (zdt.getYear() >= 1969 && zdt.getYear() < 1972) {
            // from 1968-02-18 to 1971-10-31, permanent UTC+1
            assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
            assertEquals(test.getOffset(instant), OFFSET_PONE, zdt.toString());
        } else {
            assertEquals(test.getStandardOffset(instant), OFFSET_ZERO, zdt.toString());
            assertEquals(test.getOffset(instant), zdt.getMonth() == Month.JANUARY ? OFFSET_ZERO : OFFSET_PONE, zdt.toString());
        }
        zdt = zdt.plusMonths(6);
    }
}
 
示例7
@Test
public void test_previous() {
    for (Month month : Month.values()) {
        for (int i = 1; i <= month.length(false); i++) {
            LocalDate date = date(2007, month, i);

            for (DayOfWeek dow : DayOfWeek.values()) {
                LocalDate test = (LocalDate) TemporalAdjusters.previous(dow).adjustInto(date);

                assertSame(test.getDayOfWeek(), dow, date + " " + test);

                if (test.getYear() == 2007) {
                    int dayDiff = test.getDayOfYear() - date.getDayOfYear();
                    assertTrue(dayDiff < 0 && dayDiff > -8, dayDiff + " " + test);
                } else {
                    assertSame(month, Month.JANUARY);
                    assertTrue(date.getDayOfMonth() < 8);
                    assertEquals(test.getYear(), 2006);
                    assertSame(test.getMonth(), Month.DECEMBER);
                    assertTrue(test.getDayOfMonth() > 24);
                }
            }
        }
    }
}
 
示例8
@Test
public void test_appendTextMap() throws Exception {
    Map<Long, String> map = new HashMap<Long, String>();
    map.put(1L, "JNY");
    map.put(2L, "FBY");
    map.put(3L, "MCH");
    map.put(4L, "APL");
    map.put(5L, "MAY");
    map.put(6L, "JUN");
    map.put(7L, "JLY");
    map.put(8L, "AGT");
    map.put(9L, "SPT");
    map.put(10L, "OBR");
    map.put(11L, "NVR");
    map.put(12L, "DBR");
    builder.appendText(MONTH_OF_YEAR, map);
    DateTimeFormatter f = builder.toFormatter();
    LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0);
    for (Month month : Month.values()) {
        assertEquals(f.format(dt.with(month)), map.get((long) month.getValue()));
    }
}
 
示例9
@Test
public void test_getters_floatingWeek() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.getMonth(), Month.MARCH);
    assertEquals(test.getDayOfMonthIndicator(), 20);
    assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(test.getLocalTime(), TIME_0100);
    assertEquals(test.isMidnightEndOfDay(), false);
    assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
    assertEquals(test.getStandardOffset(), OFFSET_0200);
    assertEquals(test.getOffsetBefore(), OFFSET_0200);
    assertEquals(test.getOffsetAfter(), OFFSET_0300);
    assertSerializable(test);
}
 
示例10
@Test
public void test_getters_floatingWeekBackwards() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.getMonth(), Month.MARCH);
    assertEquals(test.getDayOfMonthIndicator(), -1);
    assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY);
    assertEquals(test.getLocalTime(), TIME_0100);
    assertEquals(test.isMidnightEndOfDay(), false);
    assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
    assertEquals(test.getStandardOffset(), OFFSET_0200);
    assertEquals(test.getOffsetBefore(), OFFSET_0200);
    assertEquals(test.getOffsetAfter(), OFFSET_0300);
    assertSerializable(test);
}
 
示例11
@Test
public void test_getters_fixedDate() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(test.getMonth(), Month.MARCH);
    assertEquals(test.getDayOfMonthIndicator(), 20);
    assertEquals(test.getDayOfWeek(), null);
    assertEquals(test.getLocalTime(), TIME_0100);
    assertEquals(test.isMidnightEndOfDay(), false);
    assertEquals(test.getTimeDefinition(), TimeDefinition.WALL);
    assertEquals(test.getStandardOffset(), OFFSET_0200);
    assertEquals(test.getOffsetBefore(), OFFSET_0200);
    assertEquals(test.getOffsetAfter(), OFFSET_0300);
    assertSerializable(test);
}
 
示例12
@Test
public void test_parseMonthDayTime_maySatAfter50220u() throws Exception {
    TzdbZoneRulesCompiler test = new TzdbZoneRulesCompiler("2010c", new ArrayList<File>(), null, false);
    TZDBRule mdt = parseMonthDayTime(test, "May Sat>=5 2:20u");
    assertEquals(mdt.month, Month.MAY);
    assertEquals(mdt.dayOfWeek, DayOfWeek.SATURDAY);
    assertEquals(mdt.dayOfMonth, 5);
    assertEquals(mdt.adjustForwards, true);
    assertEquals(mdt.time, LocalTime.of(2, 20));
    assertEquals(mdt.adjustDays, 0);
    assertEquals(mdt.timeDefinition, TimeDefinition.UTC);
}
 
示例13
@Test
public void test_equals_dayOfWeekDifferentNull() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
}
 
示例14
/**
 * Adds a multi-year transition rule to the current window.
 * <p>
 * This adds a rule such that the offset, expressed as a daylight savings amount,
 * changes at the specified date-time for each year in the range.
 *
 * @param startYear  the start year of the rule, from MIN_VALUE to MAX_VALUE
 * @param endYear  the end year of the rule, from MIN_VALUE to MAX_VALUE
 * @param month  the month of the transition, not null
 * @param dayOfMonthIndicator  the day-of-month of the transition, adjusted by dayOfWeek,
 *   from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
 * @param dayOfWeek  the day-of-week to adjust to, null if day-of-month should not be adjusted
 * @param time  the time that the transition occurs as defined by timeDefintion, not null
 * @param timeEndOfDay  whether midnight is at the end of day
 * @param timeDefinition  the definition of how to convert local to actual time, not null
 * @param savingAmountSecs  the amount of saving from the standard offset after the transition in seconds
 * @return this, for chaining
 * @throws DateTimeException if a date-time field is out of range
 * @throws IllegalArgumentException if the day of month indicator is invalid
 * @throws IllegalArgumentException if the end of day midnight flag does not match the time
 * @throws IllegalStateException if no window has yet been added
 * @throws IllegalStateException if the window already has fixed savings
 * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
 */
public ZoneRulesBuilder addRuleToWindow(
        int startYear,
        int endYear,
        Month month,
        int dayOfMonthIndicator,
        DayOfWeek dayOfWeek,
        LocalTime time,
        boolean timeEndOfDay,
        TimeDefinition timeDefinition,
        int savingAmountSecs) {
    Jdk8Methods.requireNonNull(month, "month");
    Jdk8Methods.requireNonNull(time, "time");
    Jdk8Methods.requireNonNull(timeDefinition, "timeDefinition");
    YEAR.checkValidValue(startYear);
    YEAR.checkValidValue(endYear);
    if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
        throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
    }
    if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
        throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
    }
    if (windowList.isEmpty()) {
        throw new IllegalStateException("Must add a window before adding a rule");
    }
    TZWindow window = windowList.get(windowList.size() - 1);
    window.addRule(startYear, endYear, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay ? 1 : 0, timeDefinition, savingAmountSecs);
    return this;
}
 
示例15
@Test
public void test_parseMonthDayTime_jun50220s() throws Exception {
    TzdbZoneRulesCompiler test = new TzdbZoneRulesCompiler("2010c", new ArrayList<File>(), null, false);
    TZDBRule mdt = parseMonthDayTime(test, "Jun 5 2:20s");
    assertEquals(mdt.month, Month.JUNE);
    assertEquals(mdt.dayOfWeek, null);
    assertEquals(mdt.dayOfMonth, 5);
    assertEquals(mdt.adjustForwards, true);
    assertEquals(mdt.time, LocalTime.of(2, 20));
    assertEquals(mdt.adjustDays, 0);
    assertEquals(mdt.timeDefinition, TimeDefinition.STANDARD);
}
 
示例16
@Test
public void test_createTransition_floatingWeekBackwards_seventhLast() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = new ZoneOffsetTransition(
            LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
 
示例17
/**
 * Constructor.
 *
 * @param year  the year
 * @param month  the month, not null
 * @param dayOfMonthIndicator  the day-of-month of the transition, adjusted by dayOfWeek,
 *   from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
 * @param dayOfWeek  the day-of-week, null if day-of-month is exact
 * @param time  the time, not null
 * @param adjustDays  the time day adjustment
 * @param timeDefinition  the time definition, not null
 * @param savingAfterSecs  the savings amount in seconds
 */
TZRule(int year, Month month, int dayOfMonthIndicator,
        DayOfWeek dayOfWeek, LocalTime time, int adjustDays,
        TimeDefinition timeDefinition, int savingAfterSecs) {
    super();
    this.year = year;
    this.month = month;
    this.dayOfMonthIndicator = dayOfMonthIndicator;
    this.dayOfWeek = dayOfWeek;
    this.time= time;
    this.adjustDays= adjustDays;
    this.timeDefinition = timeDefinition;
    this.savingAmountSecs = savingAfterSecs;
}
 
示例18
@Test
public void test_createTransition_floatingWeekBackwards_last() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = new ZoneOffsetTransition(
            LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
 
示例19
@Test
public void test_toString_floatingWeek_overlap_endOfDay() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0300, OFFSET_0200);
    assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]");
}
 
示例20
@Test
public void now_Clock() {
    Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC);
    Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
    MonthDay test = MonthDay.now(clock);
    assertEquals(test.getMonth(), Month.DECEMBER);
    assertEquals(test.getDayOfMonth(), 31);
}
 
示例21
@Test
public void test_equals_monthDifferent() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
            Month.APRIL, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
}
 
示例22
@Test
public void test_equals_dayOfMonthDifferent() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
            Month.MARCH, 21, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
}
 
示例23
@Test
public void test_equals_timeDefinitionDifferent() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.STANDARD,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
}
 
示例24
@Test
public void test_createTransition_floatingWeek_gap_notEndOfDay() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = new ZoneOffsetTransition(
            LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
 
示例25
@Test
public void now_Clock() {
    Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC);
    Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
    YearMonth test = YearMonth.now(clock);
    assertEquals(test.getYear(), 2010);
    assertEquals(test.getMonth(), Month.DECEMBER);
}
 
示例26
private Month parseMonth(TzdbZoneRulesCompiler test, String str) throws Exception {
    try {
        return (Month) PARSE_MONTH.invoke(test, str);
    } catch (InvocationTargetException ex) {
        if (ex.getCause() != null) {
            throw (Exception) ex.getCause();
        }
        throw ex;
    }
}
 
示例27
@Test
public void test_equals_endOfDayDifferent() {
    ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(
            Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL,
            OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
}
 
示例28
@Test
public void test_firstDayOfMonth_leap() {
    for (Month month : Month.values()) {
        for (int i = 1; i <= month.length(true); i++) {
            LocalDate date = date(2008, month, i);
            LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date);
            assertEquals(test.getYear(), 2008);
            assertEquals(test.getMonth(), month);
            assertEquals(test.getDayOfMonth(), 1);
        }
    }
}
 
示例29
@Test
public void test_lastDayOfMonth_nonLeap() {
    for (Month month : Month.values()) {
        for (int i = 1; i <= month.length(false); i++) {
            LocalDate date = date(2007, month, i);
            LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfMonth().adjustInto(date);
            assertEquals(test.getYear(), 2007);
            assertEquals(test.getMonth(), month);
            assertEquals(test.getDayOfMonth(), month.length(false));
        }
    }
}
 
示例30
@Test
public void test_lastDayOfMonth_leap() {
    for (Month month : Month.values()) {
        for (int i = 1; i <= month.length(true); i++) {
            LocalDate date = date(2008, month, i);
            LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfMonth().adjustInto(date);
            assertEquals(test.getYear(), 2008);
            assertEquals(test.getMonth(), month);
            assertEquals(test.getDayOfMonth(), month.length(true));
        }
    }
}