Open In App

JapaneseChronology date(int, int, int) method in Java with Example

Last Updated : 25 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The date() method of java.time.chrono.JapaneseChronology class is used get the local date according to japanese calendar system for the given year, month and day.
Syntax: 

public JapaneseDate date(int prolepticYear,
                         int month,
                         int dayOfMonth)

Parameter: This method takes the following arguments as parameter. 

  • prolepticYear: integer proleptic year for the year field of Japanese
  • month: integer month for the month field of Japanese
  • day: integer day for the day field of Japanese

Return Value: This method returns the Japanese date according to Japanese calendar system for the given year, month and day.
Exception: This method throws DateTimeException if the given field of day, month and year are unable to form a structured date.
Below are the examples to illustrate the date() method:
Example 1: 

Java




// Java program to demonstrate
// date() method
 
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
 
public class GFG {
    public static void main(String[] argv)
    {
        try {
            // creating and initializing
            // JapaneseDate Object
            JapaneseDate lodate
                = JapaneseDate.now();
 
            // getting JapaneseChronology
            // used in JapaneseDate
            JapaneseChronology crono
                = lodate.getChronology();
 
            // getting JapaneseDate for the
            // given date, month and year field
            // by using date() method
            JapaneseDate date
                = crono.date(2018, 05, 24);
 
            // display the result
            System.out.println(
                "JapaneseDate is: "
                + date);
        }
        catch (DateTimeException e) {
            System.out.println("passed parameter can "
                               + "not form a date");
            System.out.println("Exception thrown: " + e);
        }
    }
}


Output: 

JapaneseDate is: Japanese Heisei 30-05-24

 

Example 2: 

Java




// Java program to demonstrate
// date() method
 
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
 
public class GFG {
    public static void main(String[] argv)
    {
        try {
            // creating and initializing
            // JapaneseDate Object
            JapaneseDate lodate
                = JapaneseDate.now();
 
            // getting JapaneseChronology
            // used in JapaneseDate
            JapaneseChronology crono
                = lodate.getChronology();
 
            // getting JapaneseDate for the
            // given date, month and year field
            // by using date() method
            JapaneseDate date
                = crono.date(1440, 05, 24);
 
            // display the result
            System.out.println(
                "JapaneseDate is: "
                + date);
        }
        catch (DateTimeException e) {
            System.out.println(
                "passed parameter can "
                + "not form a date");
            System.out.println(
                "Exception thrown: " + e);
        }
    }
}


Output

passed parameter can not form a date
Exception thrown: java.time.DateTimeException: JapaneseDate before Meiji 6 is not supported

Reference: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/JapaneseChronology.html#date-int-int-int-



Similar Reads

JapaneseChronology dateYearDay(int, int) method in Java with Example
The dateYearDay() method of java.time.chrono.JapaneseChronology class is used to retrieve the Japanese date according to the Iso calendar for the particular year and date.Syntax: public JapaneseDate dateYearDay( int prolepticYear, int dayOfYear) Parameter: This method takes the following arguments as parameter: year: which is the integer proleptic
2 min read
JapaneseChronology dateYearDay(Era, int, int) method in Java with Example
The dateYearDay() method of java.time.chrono.JapaneseChronology class is used to retrieve the Japanese date according to the japanese calendar for the particular era. Syntax: public JapaneseDate dateYearDay( Era era, int yearOfEra, int dayOfYear) Parameter: This method takes the following arguments as parameter: era: which is the object of type era
2 min read
TimeZone getOffset(int, int, int, int, int, int) Method in Java with Examples
The getOffset(int era, int yr, int mon, int day, int dayOfWeek, int millisec) method of TimeZone class in Java is used to know the offset value of this TimeZone at a specific date or modified date in case of daylight savings, from the UTC or the Universal Time Coordinated. This offset value can be added to get the local time. Syntax: public abstrac
2 min read
JapaneseChronology date(TemporalAccessor) method in Java with Example
The date() method of java.time.chrono.JapaneseChronology class is used get the japanese date according to Japanese calendar system from the another TemporalAccessor object . Syntax: public JapaneseDate date(TemporalAccessor temporal) Parameter: This method takes the object of any temporal accessor as a parameter. Return Value: This method returns t
2 min read
IsoChronology date(int, int, int) method in Java with Example
The date() method of java.time.chrono.IsoChronology class is used get the local date according to ISO calendar system for the given year, month and day. Syntax: public LocalDate date(int prolepticYear, int month, int dayOfMonth) Parameter: This method takes the following arguments as parameter. prolepticYear: integer proleptic year for the year fie
2 min read
MinguoChronology date(int, int, int) method in Java with Example
The date() method of java.time.chrono.MinguoChronology class is used get the local date according to Minguo calendar system for the given year, month and day.Syntax: public MinguoDate date(int prolepticYear, int month, int dayOfMonth) Parameter: This method takes the following arguments as parameter. prolepticYear: integer proleptic year for the ye
2 min read
JapaneseChronology zonedDateTime(TemporalAccessor) method in Java with Example
The zonedDateTime() method of java.time.chrono.JapaneseChronology class is used get the zonal date and time according to Japanese calendar system from the another TemporalAccessor object. Syntax: public ZonedDateTime zonedDateTime( TemporalAccessor temporal) Parameter: This method takes the object of any temporal accessor as a parameter. Return Val
2 min read
JapaneseChronology isLeapYear() method in Java with Example
The isLeapYear() method of java.time.chrono.JapaneseChronology class is used to differentiate between a leap year and a non leap year. If it is a leap year it will return true otherwise false. Syntax: public boolean isLeapYear(long prolepticYear) Parameter: This method takes prolepticYear as a parameter for checking if it is a leap year or not. Ret
2 min read
JapaneseChronology getId() method in Java with Example
The getId() method of java.time.chrono.JapaneseChronology class is used to retrieve the identification status for the particular chronology for which getId() method is revoked. Syntax: public String getId() Parameter: This method does not accept any argument as a parameter. Return Value: This method returns the identification status for the particu
2 min read
JapaneseChronology getCalendarType() method in Java with Example
The getCalendarType() method of java.time.chrono.JapaneseChronology class is used to retrieve the type of calendar lies under this Japanese chronological system.Syntax: public String getCalendarType() Parameter: This method does not accept any argument as a parameter.Return Value: This method returns the type of calendar lies under this Japanese ch
2 min read
Practice Tags :