ThaiBuddhistDate atTime() method in Java, example
Original text: https://www . geeksforgeeks . org/thaibudhistate-attime-method-in-Java-with-example/
The atTime() method of Java . time . chrono . thaibudhistate class is used to get the thaibudhist date from another TemporalAccessor object according to the thaibudhist calendar system and time.
Syntax:
public ChronoLocalDateTime
atTime(LocalTime localTime)
Parameters: This method takes an object of type LocalTime as parameter.
Return Value: This method returns a ChronoLocalDateTime by adding this ThaiBuddhist date to the elapsed local time. A spatiotemporal datetime is a datetime that does not have a time zone within an arbitrary timetable. It is intended for advanced globalization use cases.
The following is an example illustrating the atTime() method:
Example 1:
// Java program to demonstrate
// atTime() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
public class GFG {
public static void main(String[] argv)
{
try {
"n">ThaiBuddhistDate hidate
= ThaiBuddhistDate.now();
// Creating and initializing
// TemporalAccessor object
LocalTime localtime
= LocalTime.= span>now();
// Getting the Chrono Local date
// time by using atTime() method
ChronoLocalDateTime <ThaiBuddhistDate> date
="o">= hidate.atTime(localtime);
// Display the result
System.out.println(
>"Chrono LocalDateTime is: "
+ date);
}
catch (DateTimeException e) {
System.out.println(
"Passed parameter can"
+ " not form a date");
System.out .println(
> + e);
}
}
}
Output:
Chrono LocalDateTime is :
ThaiBuddhist BE 2563-05-03T13:16:55.338
Example 2:
// Java program to demonstrate
// atTime() 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
> >ThaiBuddhistDate.now();
// Creating and initializing
span> localtime
= LocalTime.of(8, 20);
the Chrono Local date
// time by using atTime() method
class="o"><ThaiBuddhistDate> date
= hidate. atTime(localtime);
class="c1">// Display the result
System.out.println(
span class="s">"Chrono LocalDateTime is: "
+ date);
}
catch (DateTimeException e) {
System.out.println(
" Passed parameter can"
+ " not form a date" );
System.out.println(
thrown: " + e);
}
}
}
Output:
Chrono LocalDateTime is:
ThaiBuddhist BE 2563- 05-03T08:20
Reference:https://docs.Oracle . com/javase/9/docs/API/Java/time/chrono/thaibudhistate . html # atTime-Java . time . local time-
/span> 2563–05 –03T08:20
Reference:https://docs . Oracle . com/javase/9/docs/API/Java/ time/chrono/thaibudhistate . html # atTime-Java . time . local time-