xxxxxxxxxx
The T is just a literal to separate the date from the time, and the Z means "zero hour offset" also known as "Zulu time" (UTC). If your strings always have a "Z" you can use: SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss. SSS'Z'", Locale.US); format. setTimeZone(TimeZone.07-Dec-2011
xxxxxxxxxx
import java.util.Date;
import java.text.SimpleDateFormat;
public class DateTimeExample {
public static void main(String[] args) {
// Create a Date object representing the current time
Date currentDate = new Date();
// Define the desired date and time format
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Format the Date object to the desired format
String formattedDateTime = dateFormat.format(currentDate);
// Print the formatted date and time
System.out.println("Current Date and Time: " + formattedDateTime);
}
}
xxxxxxxxxx
import java.time.LocalDate; // import the LocalDate class
public class Main {
public static void main(String[] args) {
LocalDate myObj = LocalDate.now(); // Create a date object
System.out.println(myObj); // Display the current date
}
}
xxxxxxxxxx
public static String findDay(int month, int day, int year) {
LocalDate ld=LocalDate.of(year,month,day);
return ld.getDayOfWeek().name();