org.joda.time.Chronology Java Examples

The following examples show how to use org.joda.time.Chronology. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JGenProg2017_0042_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #2
Source File: Nopol2017_0085_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #3
Source File: jKali_0030_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, advances to next leap year.
 */
private long setDayOfMonthNext(Chronology chrono, long next) {
    try {
        next = setDayOfMonth(chrono, next);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(next) == false) {
                next = chrono.year().add(next, 1);
            }
            next = setDayOfMonth(chrono, next);
        } else {
            throw e;
        }
    }
    return next;
}
 
Example #4
Source File: JGenProg2017_00141_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #5
Source File: Nopol2015_0010_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, advances to next leap year.
 */
private long setDayOfMonthNext(Chronology chrono, long next) {
    try {
        next = setDayOfMonth(chrono, next);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(next) == false) {
                next = chrono.year().add(next, 1);
            }
            next = setDayOfMonth(chrono, next);
        } else {
            throw e;
        }
    }
    return next;
}
 
Example #6
Source File: Cardumen_0069_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, retreats to previous leap year.
 */
private long setDayOfMonthPrevious(Chronology chrono, long prev) {
    try {
        prev = setDayOfMonth(chrono, prev);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(prev) == false) {
                prev = chrono.year().add(prev, -1);
            }
            prev = setDayOfMonth(chrono, prev);
        } else {
            throw e;
        }
    }
    return prev;
}
 
Example #7
Source File: jKali_0018_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, retreats to previous leap year.
 */
private long setDayOfMonthPrevious(Chronology chrono, long prev) {
    try {
        prev = setDayOfMonth(chrono, prev);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(prev) == false) {
                prev = chrono.year().add(prev, -1);
            }
            prev = setDayOfMonth(chrono, prev);
        } else {
            throw e;
        }
    }
    return prev;
}
 
Example #8
Source File: jMutRepair_0019_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, advances to next leap year.
 */
private long setDayOfMonthNext(Chronology chrono, long next) {
    try {
        next = setDayOfMonth(chrono, next);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(next) == false) {
                next = chrono.year().add(next, 1);
            }
            next = setDayOfMonth(chrono, next);
        } else {
            throw e;
        }
    }
    return next;
}
 
Example #9
Source File: Nopol2017_0085_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #10
Source File: Cardumen_00188_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #11
Source File: jMutRepair_0019_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #12
Source File: JGenProg2017_00122_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #13
Source File: Time_16_DateTimeFormatter_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Parses only the local date-time from the given text, returning a new LocalDate.
 * <p>
 * This will parse the text fully according to the formatter, using the UTC zone.
 * Once parsed, only the local date-time will be used.
 * This means that any parsed time-zone or offset field is completely ignored.
 * It also means that the zone and offset-parsed settings are ignored.
 *
 * @param text  the text to parse, not null
 * @return the parsed date-time, never null
 * @throws UnsupportedOperationException if parsing is not supported
 * @throws IllegalArgumentException if the text to parse is invalid
 * @since 2.0
 */
public LocalDateTime parseLocalDateTime(String text) {
    DateTimeParser parser = requireParser();
    
    Chronology chrono = selectChronology(null).withUTC();  // always use UTC, avoiding DST gaps
    DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, iLocale, iPivotYear, iDefaultYear);
    int newPos = parser.parseInto(bucket, text, 0);
    if (newPos >= 0) {
        if (newPos >= text.length()) {
            long millis = bucket.computeMillis(true, text);
            if (bucket.getOffsetInteger() != null) {  // treat withOffsetParsed() as being true
                int parsedOffset = bucket.getOffsetInteger();
                DateTimeZone parsedZone = DateTimeZone.forOffsetMillis(parsedOffset);
                chrono = chrono.withZone(parsedZone);
            } else if (bucket.getZone() != null) {
                chrono = chrono.withZone(bucket.getZone());
            }
            return new LocalDateTime(millis, chrono);
        }
    } else {
        newPos = ~newPos;
    }
    throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos));
}
 
Example #14
Source File: 1_DateTimeZoneBuilder.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
private long setDayOfWeek(Chronology chrono, long instant) {
    int dayOfWeek = chrono.dayOfWeek().get(instant);
    int daysToAdd = iDayOfWeek - dayOfWeek;
    if (daysToAdd != 0) {
        if (iAdvance) {
            if (daysToAdd < 0) {
                daysToAdd += 7;
            }
        } else {
            if (daysToAdd > 0) {
                daysToAdd -= 7;
            }
        }
        instant = chrono.dayOfWeek().add(instant, daysToAdd);
    }
    return instant;
}
 
Example #15
Source File: jMutRepair_0051_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, retreats to previous leap year.
 */
private long setDayOfMonthPrevious(Chronology chrono, long prev) {
    try {
        prev = setDayOfMonth(chrono, prev);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(prev) == false) {
                prev = chrono.year().add(prev, -1);
            }
            prev = setDayOfMonth(chrono, prev);
        } else {
            throw e;
        }
    }
    return prev;
}
 
Example #16
Source File: jKali_0018_s.java    From coming with MIT License 6 votes vote down vote up
private long setDayOfWeek(Chronology chrono, long instant) {
    int dayOfWeek = chrono.dayOfWeek().get(instant);
    int daysToAdd = iDayOfWeek - dayOfWeek;
    if (daysToAdd != 0) {
        if (iAdvance) {
            if (daysToAdd < 0) {
                daysToAdd += 7;
            }
        } else {
            if (daysToAdd > 0) {
                daysToAdd -= 7;
            }
        }
        instant = chrono.dayOfWeek().add(instant, daysToAdd);
    }
    return instant;
}
 
Example #17
Source File: BaseSingleFieldPeriod.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calculates the number of whole units between the two specified partial datetimes.
 * <p>
 * The two partials must contain the same fields, for example you can specify
 * two <code>LocalDate</code> objects.
 *
 * @param start  the start partial date, validated to not be null
 * @param end  the end partial date, validated to not be null
 * @param zeroInstance  the zero instance constant, must not be null
 * @return the period
 * @throws IllegalArgumentException if the partials are null or invalid
 */
protected static int between(ReadablePartial start, ReadablePartial end, ReadablePeriod zeroInstance) {
    if (start == null || end == null) {
        throw new IllegalArgumentException("ReadablePartial objects must not be null");
    }
    if (start.size() != end.size()) {
        throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
    }
    for (int i = 0, isize = start.size(); i < isize; i++) {
        if (start.getFieldType(i) != end.getFieldType(i)) {
            throw new IllegalArgumentException("ReadablePartial objects must have the same set of fields");
        }
    }
    if (DateTimeUtils.isContiguous(start) == false) {
        throw new IllegalArgumentException("ReadablePartial objects must be contiguous");
    }
    Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC();
    int[] values = chrono.get(zeroInstance, chrono.set(start, 0L), chrono.set(end, 0L));
    return values[0];
}
 
Example #18
Source File: jMutRepair_0045_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * @param standardOffset standard offset just before instant
 */
public long setInstant(int year, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    Chronology chrono = ISOChronology.getInstanceUTC();
    long millis = chrono.year().set(0, year);
    millis = chrono.monthOfYear().set(millis, iMonthOfYear);
    millis = chrono.millisOfDay().set(millis, iMillisOfDay);
    millis = setDayOfMonth(chrono, millis);

    if (iDayOfWeek != 0) {
        millis = setDayOfWeek(chrono, millis);
    }

    // Convert from local time to UTC.
    return millis - offset;
}
 
Example #19
Source File: Time_6_GJChronology_s.java    From coming with MIT License 6 votes vote down vote up
public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,
                              int millisOfDay)
    throws IllegalArgumentException
{
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay);
    }

    // Assume date is Gregorian.
    long instant = iGregorianChronology.getDateTimeMillis
        (year, monthOfYear, dayOfMonth, millisOfDay);
    if (instant < iCutoverMillis) {
        // Maybe it's Julian.
        instant = iJulianChronology.getDateTimeMillis
            (year, monthOfYear, dayOfMonth, millisOfDay);
        if (instant >= iCutoverMillis) {
            // Okay, it's in the illegal cutover gap.
            throw new IllegalArgumentException("Specified date does not exist");
        }
    }
    return instant;
}
 
Example #20
Source File: JGenProg2017_00141_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, retreats to previous leap year.
 */
private long setDayOfMonthPrevious(Chronology chrono, long prev) {
    try {
        prev = setDayOfMonth(chrono, prev);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(prev) == false) {
                prev = chrono.year().add(prev, -1);
            }
            prev = setDayOfMonth(chrono, prev);
        } else {
            throw e;
        }
    }
    return prev;
}
 
Example #21
Source File: Time_7_DateTimeFormatter_s.java    From coming with MIT License 6 votes vote down vote up
private void printTo(Writer buf, long instant, Chronology chrono) throws IOException {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example #22
Source File: Arja_00160_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * If month-day is 02-29 and year isn't leap, advances to next leap year.
 */
private long setDayOfMonthNext(Chronology chrono, long next) {
    try {
        next = setDayOfMonth(chrono, next);
    } catch (IllegalArgumentException e) {
        if (iMonthOfYear == 2 && iDayOfMonth == 29) {
            while (chrono.year().isLeap(next) == false) {
                next = chrono.year().add(next, 1);
            }
            next = setDayOfMonth(chrono, next);
        } else {
            throw e;
        }
    }
    return next;
}
 
Example #23
Source File: Nopol2017_0088_s.java    From coming with MIT License 5 votes vote down vote up
BasicChronology(Chronology base, Object param, int minDaysInFirstWeek) {
    super(base, param);

    if (minDaysInFirstWeek < 1 || minDaysInFirstWeek > 7) {
        throw new IllegalArgumentException
            ("Invalid min days in first week: " + minDaysInFirstWeek);
    }

    iMinDaysInFirstWeek = minDaysInFirstWeek;
}
 
Example #24
Source File: DateTimeFormatterBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void printTo(
        StringBuffer buf, long instant, Chronology chrono,
        int displayOffset, DateTimeZone displayZone, Locale locale) {
    try {
        DateTimeField field = iFieldType.getField(chrono);
        FormatUtils.appendPaddedInteger(buf, field.get(instant), iMinPrintedDigits);
    } catch (RuntimeException e) {
        appendUnknownString(buf, iMinPrintedDigits);
    }
}
 
Example #25
Source File: Time_18_GJChronology_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Called when applying a time zone.
 */
private GJChronology(Chronology base,
                     JulianChronology julian,
                     GregorianChronology gregorian,
                     Instant cutoverInstant) {
    super(base, new Object[] {julian, gregorian, cutoverInstant});
}
 
Example #26
Source File: jMutRepair_0029_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param standardOffset standard offset just before previous recurrence
 */
public long previous(long instant, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    // Convert from UTC to local time.
    instant += offset;

    Chronology chrono = ISOChronology.getInstanceUTC();
    long prev = chrono.monthOfYear().set(instant, iMonthOfYear);
    // Be lenient with millisOfDay.
    prev = chrono.millisOfDay().set(prev, 0);
    prev = chrono.millisOfDay().add(prev, iMillisOfDay);
    prev = setDayOfMonthPrevious(chrono, prev);

    if (iDayOfWeek == 0) {
        if (prev >= instant) {
            prev = chrono.year().add(prev, -1);
            prev = setDayOfMonthPrevious(chrono, prev);
        }
    } else {
        prev = setDayOfWeek(chrono, prev);
        if (prev >= instant) {
            prev = chrono.year().add(prev, -1);
            prev = chrono.monthOfYear().set(prev, iMonthOfYear);
            prev = setDayOfMonthPrevious(chrono, prev);
            prev = setDayOfWeek(chrono, prev);
        }
    }

    // Convert from local time to UTC.
    return prev - offset;
}
 
Example #27
Source File: Cardumen_00238_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param standardOffset standard offset just before previous recurrence
 */
public long previous(long instant, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    // Convert from UTC to local time.
    instant += offset;

    Chronology chrono = ISOChronology.getInstanceUTC();
    long prev = chrono.monthOfYear().set(instant, iMonthOfYear);
    // Be lenient with millisOfDay.
    prev = chrono.millisOfDay().set(prev, 0);
    prev = chrono.millisOfDay().add(prev, iMillisOfDay);
    prev = setDayOfMonthPrevious(chrono, prev);

    if (iDayOfWeek == 0) {
        if (prev >= instant) {
            prev = chrono.year().add(prev, -1);
            prev = setDayOfMonthPrevious(chrono, prev);
        }
    } else {
        prev = setDayOfWeek(chrono, prev);
        if (prev >= instant) {
            prev = chrono.year().add(prev, -1);
            prev = chrono.monthOfYear().set(prev, iMonthOfYear);
            prev = setDayOfMonthPrevious(chrono, prev);
            prev = setDayOfWeek(chrono, prev);
        }
    }

    // Convert from local time to UTC.
    return prev - offset;
}
 
Example #28
Source File: Elixir_0038_t.java    From coming with MIT License 5 votes vote down vote up
private long setDayOfMonth(Chronology chrono, long instant) {
    if (iDayOfMonth >= 0) {
        instant = chrono.dayOfMonth().set(instant, iDayOfMonth);
    } else {
        instant = chrono.dayOfMonth().set(instant, 1);
        instant = chrono.monthOfYear().add(instant, 1);
        instant = chrono.dayOfMonth().add(instant, iDayOfMonth);
    }
    return instant;
}
 
Example #29
Source File: jMutRepair_0019_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param standardOffset standard offset just before previous recurrence
 */
public long previous(long instant, int standardOffset, int saveMillis) {
    int offset;
    if (iMode == 'w') {
        offset = standardOffset + saveMillis;
    } else if (iMode == 's') {
        offset = standardOffset;
    } else {
        offset = 0;
    }

    // Convert from UTC to local time.
    instant += offset;

    Chronology chrono = ISOChronology.getInstanceUTC();
    long prev = chrono.monthOfYear().set(instant, iMonthOfYear);
    // Be lenient with millisOfDay.
    prev = chrono.millisOfDay().set(prev, 0);
    prev = chrono.millisOfDay().add(prev, iMillisOfDay);
    prev = setDayOfMonthPrevious(chrono, prev);

    if (iDayOfWeek == 0) {
        if (prev >= instant) {
            prev = chrono.year().add(prev, -1);
            prev = setDayOfMonthPrevious(chrono, prev);
        }
    } else {
        prev = setDayOfWeek(chrono, prev);
        if (prev >= instant) {
            prev = chrono.year().add(prev, -1);
            prev = chrono.monthOfYear().set(prev, iMonthOfYear);
            prev = setDayOfMonthPrevious(chrono, prev);
            prev = setDayOfWeek(chrono, prev);
        }
    }

    // Convert from local time to UTC.
    return prev - offset;
}
 
Example #30
Source File: TestLenientChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void test_setDayOfMonth() {
    Chronology zone = LenientChronology.getInstance(ISOChronology.getInstanceUTC());
    DateTime dt = new DateTime(2007, 1, 1, 0, 0 ,0, 0, zone);
    assertEquals("2007-01-01T00:00:00.000Z", dt.toString());
    dt = dt.withDayOfMonth(32);
    assertEquals("2007-02-01T00:00:00.000Z", dt.toString());
    dt = dt.withDayOfMonth(0);
    assertEquals("2007-01-31T00:00:00.000Z", dt.toString());
}