ThaiBuddhistDate now(Clock) method in Java with ExampleThe java.time.chrono.ThaiBuddhistDate is a class containing a now() as a function. The ThaiBuddhistDate class is used to retrieve the current ThaiBuddhist date from the given clock that is compatible with the ThaiBuddhist calendar system. Syntax: Parameter: In accordance with this method, the Thai Buddhist date will be generated using the clock's object as the basis. Return Value: This function uses the given clock to return the current ThaiBuddhist date based on the ThaiBuddhist calendar system. Example 1:The Java program that is given shows how to interact with dates and times in various timelines and time zones by utilizing the java.time package. Using Clock.systemUTC(), the software initializes a Clock object set to the UTC time zone. Next, using the UTC clock as the current time, it constructs a ThaiBuddhistDate object that represents the current date in the Thai Buddhist calendar. This date is printed to the console by the program itself. The program detects and handles DateTimeExceptions, which happen when the ThaiBuddhistDate is being created. The exception details are printed along with an error message. Implementation: FileName: UTCTimeDate.java Output: ThaiBuddhistDate: ThaiBuddhist BE 2567-05-27 Example 2:The corresponding Java program shows how to use the system's default time zone to build and display the current date in the Thai Buddhist calendar. By calling Clock.systemDefaultZone() to obtain the system's default time zone clock, the program creates an initialized Clock object. On the basis of this default time zone clock, it then constructs a ThaiBuddhistDate object that represents the current date in the Thai Buddhist calendar. It is on this date that the application prints to the terminal. The ThaiBuddhistDate captures DateTimeExceptions and shows an error message and the specifics of the exception if one happens during the date creation process. Implementation: FileName: DefaultZoneTimeDate.java Output: ThaiBuddhistDate: ThaiBuddhist BE 2567-05-27 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India