org.threeten.bp.DateTimeException Java Examples
The following examples show how to use
org.threeten.bp.DateTimeException.
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: TestNumberPrinter.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test(dataProvider="Pad") public void test_pad_NOT_NEGATIVE(int minPad, int maxPad, long value, String result) throws Exception { printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value)); NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.NOT_NEGATIVE); try { pp.print(printContext, buf); if (result == null || value < 0) { fail("Expected exception"); } assertEquals(buf.toString(), result); } catch (DateTimeException ex) { if (result == null || value < 0) { assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); } else { throw ex; } } }
Example #2
Source File: ChronoPeriodImpl.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Temporal subtractFrom(Temporal temporal) { Jdk8Methods.requireNonNull(temporal, "temporal"); Chronology temporalChrono = temporal.query(TemporalQueries.chronology()); if (temporalChrono != null && chronology.equals(temporalChrono) == false) { throw new DateTimeException("Invalid chronology, required: " + chronology.getId() + ", but was: " + temporalChrono.getId()); } if (years != 0) { temporal = temporal.minus(years, YEARS); } if (months != 0) { temporal = temporal.minus(months, MONTHS); } if (days != 0) { temporal = temporal.minus(days, DAYS); } return temporal; }
Example #3
Source File: DateTimeFormatterBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Constructor. * * @param field the field to print, validated not null * @param width the field width, from 1 to 10 * @param maxWidth the field max width, from 1 to 10 * @param baseValue the base value * @param baseDate the base date */ ReducedPrinterParser(TemporalField field, int width, int maxWidth, int baseValue, ChronoLocalDate baseDate) { super(field, width, maxWidth, SignStyle.NOT_NEGATIVE); if (width < 1 || width > 10) { throw new IllegalArgumentException("The width must be from 1 to 10 inclusive but was " + width); } if (maxWidth < 1 || maxWidth > 10) { throw new IllegalArgumentException("The maxWidth must be from 1 to 10 inclusive but was " + maxWidth); } if (maxWidth < width) { throw new IllegalArgumentException("The maxWidth must be greater than the width"); } if (baseDate == null) { if (field.range().isValidValue(baseValue) == false) { throw new IllegalArgumentException("The base value must be within the range of the field"); } if ((((long) baseValue) + EXCEED_POINTS[width]) > Integer.MAX_VALUE) { throw new DateTimeException("Unable to add printer-parser as the range exceeds the capacity of an int"); } } this.baseValue = baseValue; this.baseDate = baseDate; }
Example #4
Source File: ChronoPeriodImpl.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Temporal addTo(Temporal temporal) { Jdk8Methods.requireNonNull(temporal, "temporal"); Chronology temporalChrono = temporal.query(TemporalQueries.chronology()); if (temporalChrono != null && chronology.equals(temporalChrono) == false) { throw new DateTimeException("Invalid chronology, required: " + chronology.getId() + ", but was: " + temporalChrono.getId()); } if (years != 0) { temporal = temporal.plus(years, YEARS); } if (months != 0) { temporal = temporal.plus(months, MONTHS); } if (days != 0) { temporal = temporal.plus(days, DAYS); } return temporal; }
Example #5
Source File: DateTimeFormatterBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean print(DateTimePrintContext context, StringBuilder buf) { int preLen = buf.length(); if (printerParser.print(context, buf) == false) { return false; } int len = buf.length() - preLen; if (len > padWidth) { throw new DateTimeException( "Cannot print as output of " + len + " characters exceeds pad width of " + padWidth); } for (int i = 0; i < padWidth - len; i++) { buf.insert(preLen, padChar); } return true; }
Example #6
Source File: DateTimeFormatter.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Formats a date-time object to an {@code Appendable} using this formatter. * <p> * This formats the date-time to the specified destination. * {@link Appendable} is a general purpose interface that is implemented by all * key character output classes including {@code StringBuffer}, {@code StringBuilder}, * {@code PrintStream} and {@code Writer}. * <p> * Although {@code Appendable} methods throw an {@code IOException}, this method does not. * Instead, any {@code IOException} is wrapped in a runtime exception. * * @param temporal the temporal object to print, not null * @param appendable the appendable to print to, not null * @throws DateTimeException if an error occurs during formatting */ public void formatTo(TemporalAccessor temporal, Appendable appendable) { Jdk8Methods.requireNonNull(temporal, "temporal"); Jdk8Methods.requireNonNull(appendable, "appendable"); try { DateTimePrintContext context = new DateTimePrintContext(temporal, this); if (appendable instanceof StringBuilder) { printerParser.print(context, (StringBuilder) appendable); } else { // buffer output to avoid writing to appendable in case of error StringBuilder buf = new StringBuilder(32); printerParser.print(context, buf); appendable.append(buf); } } catch (IOException ex) { throw new DateTimeException(ex.getMessage(), ex); } }
Example #7
Source File: ChronoDateImpl.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SuppressWarnings("unchecked") @Override public ChronoDateImpl<D> plus(long amountToAdd, TemporalUnit unit) { if (unit instanceof ChronoUnit) { ChronoUnit f = (ChronoUnit) unit; switch (f) { case DAYS: return plusDays(amountToAdd); case WEEKS: return plusDays(Jdk8Methods.safeMultiply(amountToAdd, 7)); case MONTHS: return plusMonths(amountToAdd); case YEARS: return plusYears(amountToAdd); case DECADES: return plusYears(Jdk8Methods.safeMultiply(amountToAdd, 10)); case CENTURIES: return plusYears(Jdk8Methods.safeMultiply(amountToAdd, 100)); case MILLENNIA: return plusYears(Jdk8Methods.safeMultiply(amountToAdd, 1000)); // case ERAS: throw new DateTimeException("Unable to add era, standard calendar system only has one era"); // case FOREVER: return (period == 0 ? this : (period > 0 ? LocalDate.MAX_DATE : LocalDate.MIN_DATE)); } throw new DateTimeException(unit + " not valid for chronology " + getChronology().getId()); } return (ChronoDateImpl<D>) getChronology().ensureChronoLocalDate(unit.addTo(this, amountToAdd)); }
Example #8
Source File: TestNumberPrinter.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test(dataProvider="Pad") public void test_pad_NORMAL(int minPad, int maxPad, long value, String result) throws Exception { printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value)); NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL); try { pp.print(printContext, buf); if (result == null) { fail("Expected exception"); } assertEquals(buf.toString(), (value < 0 ? "-" + result : result)); } catch (DateTimeException ex) { if (result != null) { throw ex; } assertEquals(ex.getMessage().contains(DAY_OF_MONTH.toString()), true); } }
Example #9
Source File: JapaneseDate.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Obtains a {@code JapaneseDate} representing a date in the Japanese calendar * system from the era, year-of-era and day-of-year fields. * <p> * This returns a {@code JapaneseDate} with the specified fields. * The day must be valid for the year, otherwise an exception will be thrown. * The Japanese day-of-year is reset when the era changes. * * @param era the Japanese era, not null * @param yearOfEra the Japanese year-of-era * @param dayOfYear the Japanese day-of-year, from 1 to 31 * @return the date in Japanese calendar system, not null * @throws DateTimeException if the value of any field is out of range, * or if the day-of-year is invalid for the year */ static JapaneseDate ofYearDay(JapaneseEra era, int yearOfEra, int dayOfYear) { Jdk8Methods.requireNonNull(era, "era"); if (yearOfEra < 1) { throw new DateTimeException("Invalid YearOfEra: " + yearOfEra); } LocalDate eraStartDate = era.startDate(); LocalDate eraEndDate = era.endDate(); if (yearOfEra == 1) { dayOfYear += eraStartDate.getDayOfYear() - 1; if (dayOfYear > eraStartDate.lengthOfYear()) { throw new DateTimeException("DayOfYear exceeds maximum allowed in the first year of era " + era); } } int yearOffset = eraStartDate.getYear() - 1; LocalDate isoDate = LocalDate.ofYearDay(yearOfEra + yearOffset, dayOfYear); if (isoDate.isBefore(eraStartDate) || isoDate.isAfter(eraEndDate)) { throw new DateTimeException("Requested date is outside bounds of era " + era); } return new JapaneseDate(era, yearOfEra, isoDate); }
Example #10
Source File: TestDateTimeFormatters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@DataProvider(name="sample_isoDate") Object[][] provider_sample_isoDate() { return new Object[][]{ {2008, null, null, null, null, null, DateTimeException.class}, {null, 6, null, null, null, null, DateTimeException.class}, {null, null, 30, null, null, null, DateTimeException.class}, {null, null, null, "+01:00", null, null, DateTimeException.class}, {null, null, null, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, null, null, null, null, DateTimeException.class}, {null, 6, 30, null, null, null, DateTimeException.class}, {2008, 6, 30, null, null, "2008-06-30", null}, {2008, 6, 30, "+01:00", null, "2008-06-30+01:00", null}, {2008, 6, 30, "+01:00", "Europe/Paris", "2008-06-30+01:00", null}, {2008, 6, 30, null, "Europe/Paris", "2008-06-30", null}, {123456, 6, 30, "+01:00", "Europe/Paris", "+123456-06-30+01:00", null}, }; }
Example #11
Source File: TestDateTimeFormatters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DataProvider(name="sample_isoOffsetTime") Object[][] provider_sample_isoOffsetTime() { return new Object[][]{ {11, null, null, null, null, null, null, DateTimeException.class}, {null, 5, null, null, null, null, null, DateTimeException.class}, {null, null, 30, null, null, null, null, DateTimeException.class}, {null, null, null, 1, null, null, null, DateTimeException.class}, {null, null, null, null, "+01:00", null, null, DateTimeException.class}, {null, null, null, null, null, "Europe/Paris", null, DateTimeException.class}, {11, 5, null, null, null, null, null, DateTimeException.class}, {11, 5, 30, null, null, null, null, DateTimeException.class}, {11, 5, 30, 500000000, null, null, null, DateTimeException.class}, {11, 5, 30, 1, null, null, null, DateTimeException.class}, {11, 5, null, null, "+01:00", null, "11:05+01:00", null}, {11, 5, 30, null, "+01:00", null, "11:05:30+01:00", null}, {11, 5, 30, 500000000, "+01:00", null, "11:05:30.5+01:00", null}, {11, 5, 30, 1, "+01:00", null, "11:05:30.000000001+01:00", null}, {11, 5, null, null, "+01:00", "Europe/Paris", "11:05+01:00", null}, {11, 5, 30, null, "+01:00", "Europe/Paris", "11:05:30+01:00", null}, {11, 5, 30, 500000000, "+01:00", "Europe/Paris", "11:05:30.5+01:00", null}, {11, 5, 30, 1, "+01:00", "Europe/Paris", "11:05:30.000000001+01:00", null}, {11, 5, null, null, null, "Europe/Paris", null, DateTimeException.class}, {11, 5, 30, null, null, "Europe/Paris", null, DateTimeException.class}, {11, 5, 30, 500000000, null, "Europe/Paris", null, DateTimeException.class}, {11, 5, 30, 1, null, "Europe/Paris", null, DateTimeException.class}, }; }
Example #12
Source File: DateTimePrintContext.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Gets the value of the specified field. * <p> * This will return the value for the specified field. * * @param field the field to find, not null * @return the value, null if not found and optional is true * @throws DateTimeException if the field is not available and the section is not optional */ Long getValue(TemporalField field) { try { return temporal.getLong(field); } catch (DateTimeException ex) { if (optional > 0) { return null; } throw ex; } }
Example #13
Source File: DateTimeBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void resolveMakeChanges(TemporalField targetField, ChronoLocalDate date) { if (chrono.equals(date.getChronology()) == false) { throw new DateTimeException("ChronoLocalDate must use the effective parsed chronology: " + chrono); } long epochDay = date.toEpochDay(); Long old = fieldValues.put(ChronoField.EPOCH_DAY, epochDay); if (old != null && old.longValue() != epochDay) { throw new DateTimeException("Conflict found: " + LocalDate.ofEpochDay(old) + " differs from " + LocalDate.ofEpochDay(epochDay) + " while resolving " + targetField); } }
Example #14
Source File: MockFieldValue.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { return field.range(); } throw new DateTimeException("Unsupported field: " + field); } return field.rangeRefinedBy(this); }
Example #15
Source File: DateTimeBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public long getLong(TemporalField field) { Jdk8Methods.requireNonNull(field, "field"); Long value = getFieldValue0(field); if (value == null) { if (date != null && date.isSupported(field)) { return date.getLong(field); } if (time != null && time.isSupported(field)) { return time.getLong(field); } throw new DateTimeException("Field not found: " + field); } return value; }
Example #16
Source File: ChronoPeriodImpl.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public ChronoPeriod minus(TemporalAmount amountToSubtract) { if (amountToSubtract instanceof ChronoPeriodImpl) { ChronoPeriodImpl amount = (ChronoPeriodImpl) amountToSubtract; if (amount.getChronology().equals(getChronology())) { return new ChronoPeriodImpl( chronology, Jdk8Methods.safeSubtract(years, amount.years), Jdk8Methods.safeSubtract(months, amount.months), Jdk8Methods.safeSubtract(days, amount.days)); } } throw new DateTimeException("Unable to subtract amount: " + amountToSubtract); }
Example #17
Source File: HijrahChronology.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public HijrahEra eraOf(int eraValue) { switch (eraValue) { case 0: return HijrahEra.BEFORE_AH; case 1: return HijrahEra.AH; default: throw new DateTimeException("invalid Hijrah era"); } }
Example #18
Source File: TestDateTimeFormatters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DataProvider(name="sample_isoLocalDateTime") Object[][] provider_sample_isoLocalDateTime() { return new Object[][]{ {2008, null, null, null, null, null, null, null, null, null, DateTimeException.class}, {null, 6, null, null, null, null, null, null, null, null, DateTimeException.class}, {null, null, 30, null, null, null, null, null, null, null, DateTimeException.class}, {null, null, null, 11, null, null, null, null, null, null, DateTimeException.class}, {null, null, null, null, 5, null, null, null, null, null, DateTimeException.class}, {null, null, null, null, null, null, null, "+01:00", null, null, DateTimeException.class}, {null, null, null, null, null, null, null, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, 30, 11, null, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, null, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, null, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, null, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {null, 6, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, null, null, null, null, "2008-06-30T11:05", null}, {2008, 6, 30, 11, 5, 30, null, null, null, "2008-06-30T11:05:30", null}, {2008, 6, 30, 11, 5, 30, 500000000, null, null, "2008-06-30T11:05:30.5", null}, {2008, 6, 30, 11, 5, 30, 1, null, null, "2008-06-30T11:05:30.000000001", null}, {2008, 6, 30, 11, 5, null, null, "+01:00", null, "2008-06-30T11:05", null}, {2008, 6, 30, 11, 5, 30, null, "+01:00", null, "2008-06-30T11:05:30", null}, {2008, 6, 30, 11, 5, 30, 500000000, "+01:00", null, "2008-06-30T11:05:30.5", null}, {2008, 6, 30, 11, 5, 30, 1, "+01:00", null, "2008-06-30T11:05:30.000000001", null}, {2008, 6, 30, 11, 5, null, null, "+01:00", "Europe/Paris", "2008-06-30T11:05", null}, {2008, 6, 30, 11, 5, 30, null, "+01:00", "Europe/Paris", "2008-06-30T11:05:30", null}, {2008, 6, 30, 11, 5, 30, 500000000, "+01:00", "Europe/Paris", "2008-06-30T11:05:30.5", null}, {2008, 6, 30, 11, 5, 30, 1, "+01:00", "Europe/Paris", "2008-06-30T11:05:30.000000001", null}, {2008, 6, 30, 11, 5, null, null, null, "Europe/Paris", "2008-06-30T11:05", null}, {2008, 6, 30, 11, 5, 30, null, null, "Europe/Paris", "2008-06-30T11:05:30", null}, {2008, 6, 30, 11, 5, 30, 500000000, null, "Europe/Paris", "2008-06-30T11:05:30.5", null}, {2008, 6, 30, 11, 5, 30, 1, null, "Europe/Paris", "2008-06-30T11:05:30.000000001", null}, {123456, 6, 30, 11, 5, null, null, null, null, "+123456-06-30T11:05", null}, }; }
Example #19
Source File: HijrahDate.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Check the validity of a yearOfEra. * @param yearOfEra the year to check */ private static void checkValidYearOfEra(int yearOfEra) { if (yearOfEra < MIN_VALUE_OF_ERA || yearOfEra > MAX_VALUE_OF_ERA) { throw new DateTimeException("Invalid year of Hijrah Era"); } }
Example #20
Source File: HijrahDate.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void checkValidDayOfMonth(int dayOfMonth) { if (dayOfMonth < 1 || dayOfMonth > getMaximumDayOfMonth()) { throw new DateTimeException("Invalid day of month of Hijrah date, day " + dayOfMonth + " greater than " + getMaximumDayOfMonth() + " or less than 1"); } }
Example #21
Source File: TestDateTimeFormatters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DataProvider(name="sample_isoOffsetDateTime") Object[][] provider_sample_isoOffsetDateTime() { return new Object[][]{ {2008, null, null, null, null, null, null, null, null, null, DateTimeException.class}, {null, 6, null, null, null, null, null, null, null, null, DateTimeException.class}, {null, null, 30, null, null, null, null, null, null, null, DateTimeException.class}, {null, null, null, 11, null, null, null, null, null, null, DateTimeException.class}, {null, null, null, null, 5, null, null, null, null, null, DateTimeException.class}, {null, null, null, null, null, null, null, "+01:00", null, null, DateTimeException.class}, {null, null, null, null, null, null, null, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, 30, 11, null, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, null, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, null, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, null, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {null, 6, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, 30, null, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, 30, 500000000, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, 30, 1, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, null, null, "+01:00", null, "2008-06-30T11:05+01:00", null}, {2008, 6, 30, 11, 5, 30, null, "+01:00", null, "2008-06-30T11:05:30+01:00", null}, {2008, 6, 30, 11, 5, 30, 500000000, "+01:00", null, "2008-06-30T11:05:30.5+01:00", null}, {2008, 6, 30, 11, 5, 30, 1, "+01:00", null, "2008-06-30T11:05:30.000000001+01:00", null}, {2008, 6, 30, 11, 5, null, null, "+01:00", "Europe/Paris", "2008-06-30T11:05+01:00", null}, {2008, 6, 30, 11, 5, 30, null, "+01:00", "Europe/Paris", "2008-06-30T11:05:30+01:00", null}, {2008, 6, 30, 11, 5, 30, 500000000, "+01:00", "Europe/Paris", "2008-06-30T11:05:30.5+01:00", null}, {2008, 6, 30, 11, 5, 30, 1, "+01:00", "Europe/Paris", "2008-06-30T11:05:30.000000001+01:00", null}, {2008, 6, 30, 11, 5, null, null, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, 30, 11, 5, 30, null, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, 30, 11, 5, 30, 500000000, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, 30, 11, 5, 30, 1, null, "Europe/Paris", null, DateTimeException.class}, {123456, 6, 30, 11, 5, null, null, "+01:00", null, "+123456-06-30T11:05+01:00", null}, }; }
Example #22
Source File: JapaneseEra.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns the singleton {@code JapaneseEra} corresponding to this object. * It's possible that this version of {@code JapaneseEra} doesn't support the latest era value. * In that case, this method throws an {@code ObjectStreamException}. * * @return the singleton {@code JapaneseEra} for this object * @throws ObjectStreamException if the deserialized object has any unknown numeric era value. */ private Object readResolve() throws ObjectStreamException { try { return of(eraValue); } catch (DateTimeException e) { InvalidObjectException ex = new InvalidObjectException("Invalid era"); ex.initCause(e); throw ex; } }
Example #23
Source File: JapaneseEra.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Obtains an instance of {@code JapaneseEra} from a date. * * @param date the date, not null * @return the Era singleton, never null */ static JapaneseEra from(LocalDate date) { if (date.isBefore(MEIJI.since)) { throw new DateTimeException("Date too early: " + date); } JapaneseEra[] known = KNOWN_ERAS.get(); for (int i = known.length - 1; i >= 0; i--) { JapaneseEra era = known[i]; if (date.compareTo(era.since) >= 0) { return era; } } return null; }
Example #24
Source File: MockFieldValue.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public long getLong(TemporalField field) { if (this.field.equals(field)) { return value; } throw new DateTimeException("Unsupported field: " + field); }
Example #25
Source File: TestDateTimeFormatters.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DataProvider(name="sample_isoDateTime") Object[][] provider_sample_isoDateTime() { return new Object[][]{ {2008, null, null, null, null, null, null, null, null, null, DateTimeException.class}, {null, 6, null, null, null, null, null, null, null, null, DateTimeException.class}, {null, null, 30, null, null, null, null, null, null, null, DateTimeException.class}, {null, null, null, 11, null, null, null, null, null, null, DateTimeException.class}, {null, null, null, null, 5, null, null, null, null, null, DateTimeException.class}, {null, null, null, null, null, null, null, "+01:00", null, null, DateTimeException.class}, {null, null, null, null, null, null, null, null, "Europe/Paris", null, DateTimeException.class}, {2008, 6, 30, 11, null, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, null, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, null, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, null, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {null, 6, 30, 11, 5, null, null, null, null, null, DateTimeException.class}, {2008, 6, 30, 11, 5, null, null, null, null, "2008-06-30T11:05", null}, {2008, 6, 30, 11, 5, 30, null, null, null, "2008-06-30T11:05:30", null}, {2008, 6, 30, 11, 5, 30, 500000000, null, null, "2008-06-30T11:05:30.5", null}, {2008, 6, 30, 11, 5, 30, 1, null, null, "2008-06-30T11:05:30.000000001", null}, {2008, 6, 30, 11, 5, null, null, "+01:00", null, "2008-06-30T11:05+01:00", null}, {2008, 6, 30, 11, 5, 30, null, "+01:00", null, "2008-06-30T11:05:30+01:00", null}, {2008, 6, 30, 11, 5, 30, 500000000, "+01:00", null, "2008-06-30T11:05:30.5+01:00", null}, {2008, 6, 30, 11, 5, 30, 1, "+01:00", null, "2008-06-30T11:05:30.000000001+01:00", null}, {2008, 6, 30, 11, 5, null, null, "+01:00", "Europe/Paris", "2008-06-30T11:05+01:00[Europe/Paris]", null}, {2008, 6, 30, 11, 5, 30, null, "+01:00", "Europe/Paris", "2008-06-30T11:05:30+01:00[Europe/Paris]", null}, {2008, 6, 30, 11, 5, 30, 500000000, "+01:00", "Europe/Paris", "2008-06-30T11:05:30.5+01:00[Europe/Paris]", null}, {2008, 6, 30, 11, 5, 30, 1, "+01:00", "Europe/Paris", "2008-06-30T11:05:30.000000001+01:00[Europe/Paris]", null}, {2008, 6, 30, 11, 5, null, null, null, "Europe/Paris", "2008-06-30T11:05", null}, {2008, 6, 30, 11, 5, 30, null, null, "Europe/Paris", "2008-06-30T11:05:30", null}, {2008, 6, 30, 11, 5, 30, 500000000, null, "Europe/Paris", "2008-06-30T11:05:30.5", null}, {2008, 6, 30, 11, 5, 30, 1, null, "Europe/Paris", "2008-06-30T11:05:30.000000001", null}, {123456, 6, 30, 11, 5, null, null, null, null, "+123456-06-30T11:05", null}, }; }
Example #26
Source File: TestYearMonth.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooHigh() { YearMonth.of(2008, 13); }
Example #27
Source File: TestYear.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); }
Example #28
Source File: TestYear.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooLow() { Year.of(Year.MIN_VALUE - 1); }
Example #29
Source File: TestYearMonth.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(-1); }
Example #30
Source File: TestYear.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_plusYears_max() { Year.of(Year.MAX_VALUE).plusYears(1); }