Java Code Examples for java.time.LocalDate#ofYearDay()
The following examples show how to use
java.time.LocalDate#ofYearDay() .
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: LocalDateExample.java From journaldev with MIT License | 5 votes |
public static void main(String[] args) { // Current Date LocalDate today = LocalDate.now(); System.out.println("Current Date=" + today); // Creating LocalDate by providing input arguments LocalDate firstDay_2014 = LocalDate.of(2014, Month.JANUARY, 1); System.out.println("Specific Date=" + firstDay_2014); // Try creating date by providing invalid inputs // LocalDate feb29_2014 = LocalDate.of(2014, Month.FEBRUARY, 29); // Exception in thread "main" java.time.DateTimeException: // Invalid date 'February 29' as '2014' is not a leap year // Current date in "Asia/Kolkata", you can get it from ZoneId javadoc LocalDate todayKolkata = LocalDate.now(ZoneId.of("Asia/Kolkata")); System.out.println("Current Date in IST=" + todayKolkata); // java.time.zone.ZoneRulesException: Unknown time-zone ID: IST // LocalDate todayIST = LocalDate.now(ZoneId.of("IST")); // Getting date from the base date i.e 01/01/1970 LocalDate dateFromBase = LocalDate.ofEpochDay(365); System.out.println("365th day from base date= " + dateFromBase); LocalDate hundredDay2014 = LocalDate.ofYearDay(2014, 100); System.out.println("100th day of 2014=" + hundredDay2014); }
Example 2
Source File: LocalDatesTest.java From mockneat with Apache License 2.0 | 5 votes |
@Test public void testBetween() throws Exception { LocalDate lastCentury = LocalDate.ofYearDay(1900, 100); LocalDate nextCentury = LocalDate.ofYearDay(2150, 100); loop(Constants.LOCAL_DATES_CYCLES, Constants.MOCKS, m -> m.localDates().between(lastCentury, nextCentury).val(), d -> { assertTrue(d.compareTo(lastCentury)>=0); assertTrue(d.compareTo(nextCentury)<0); }); }
Example 3
Source File: TCKLocalDate.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_dayTooHigh() { LocalDate.ofYearDay(2007, 367); }
Example 4
Source File: TCKLocalDate.java From j2objc with Apache License 2.0 | 4 votes |
@Test(expected=DateTimeException.class) public void factory_ofYearDay_ints_yearTooLow() { LocalDate.ofYearDay(Integer.MIN_VALUE, 1); }
Example 5
Source File: TCKLocalDate.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_dayTooLow() { LocalDate.ofYearDay(2007, 0); }
Example 6
Source File: TCKLocalDate.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_yearTooLow() { LocalDate.ofYearDay(Integer.MIN_VALUE, 1); }
Example 7
Source File: TCKLocalDate.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_yearTooLow() { LocalDate.ofYearDay(Integer.MIN_VALUE, 1); }
Example 8
Source File: TCKLocalDate.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_366nonLeap() { LocalDate.ofYearDay(2007, 366); }
Example 9
Source File: TCKLocalDate.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_366nonLeap() { LocalDate.ofYearDay(2007, 366); }
Example 10
Source File: TCKLocalDate.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_yearTooLow() { LocalDate.ofYearDay(Integer.MIN_VALUE, 1); }
Example 11
Source File: MinguoChronology.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Minguo calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Minguo local date, not null * @throws DateTimeException if unable to create the date */ @Override public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); }
Example 12
Source File: JapaneseChronology.java From Java8CN with Apache License 2.0 | 2 votes |
/** * Obtains a local date in Japanese calendar system from the * proleptic-year and day-of-year fields. * <p> * The day-of-year in this factory is expressed relative to the start of the proleptic year. * The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. * They are not reset when the era changes. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Japanese local date, not null * @throws DateTimeException if unable to create the date */ @Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { return new JapaneseDate(LocalDate.ofYearDay(prolepticYear, dayOfYear)); }
Example 13
Source File: MinguoChronology.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Minguo calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Minguo local date, not null * @throws DateTimeException if unable to create the date */ @Override public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); }
Example 14
Source File: MinguoChronology.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Minguo calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Minguo local date, not null * @throws DateTimeException if unable to create the date */ @Override public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); }
Example 15
Source File: MinguoChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Minguo calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Minguo local date, not null * @throws DateTimeException if unable to create the date */ @Override public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); }
Example 16
Source File: JapaneseChronology.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Obtains a local date in Japanese calendar system from the * proleptic-year and day-of-year fields. * <p> * The day-of-year in this factory is expressed relative to the start of the proleptic year. * The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. * They are not reset when the era changes. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Japanese local date, not null * @throws DateTimeException if unable to create the date */ @Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { return new JapaneseDate(LocalDate.ofYearDay(prolepticYear, dayOfYear)); }
Example 17
Source File: ThaiBuddhistChronology.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Thai Buddhist calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Thai Buddhist local date, not null * @throws DateTimeException if unable to create the date */ @Override public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) { return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear)); }
Example 18
Source File: ThaiBuddhistChronology.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Thai Buddhist calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Thai Buddhist local date, not null * @throws DateTimeException if unable to create the date */ @Override public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) { return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear)); }
Example 19
Source File: ThaiBuddhistChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Thai Buddhist calendar system from the * proleptic-year and day-of-year fields. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Thai Buddhist local date, not null * @throws DateTimeException if unable to create the date */ @Override public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) { return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear)); }
Example 20
Source File: JapaneseChronology.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Obtains a local date in Japanese calendar system from the * proleptic-year and day-of-year fields. * <p> * The day-of-year in this factory is expressed relative to the start of the proleptic year. * The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. * They are not reset when the era changes. * * @param prolepticYear the proleptic-year * @param dayOfYear the day-of-year * @return the Japanese local date, not null * @throws DateTimeException if unable to create the date */ @Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { return new JapaneseDate(LocalDate.ofYearDay(prolepticYear, dayOfYear)); }