import java.util.Date; import java.util.Locale; public class DateExample { public static void main(String[] args) { Date date = new Date(); String strDate = date.toLocaleString(Locale.US); System.out.println(strDate); } }
import java.util.Date; import java.util.Locale; public class DateExample { public static void main(String[] args) { Date date = new Date(); String strDate = date.toLocaleString(Locale.FRANCE); System.out.println(strDate); } }In this example, the toLocaleString() method is used to get a string representation of the current date and time in the French locale. The java.util package library is used for these examples.