I want this date format YYYY-MM-DD.
Please help me on this :
java.util.Date date= new java.util.Date();
Timestamp time = new Timestamp(date.getTime());
System.out.println(time);
I want this date format YYYY-MM-DD.
Please help me on this :
java.util.Date date= new java.util.Date();
Timestamp time = new Timestamp(date.getTime());
System.out.println(time);
This should help you:
public static void main(String args[]) {
java.util.Date date = new java.util.Date();
String time = new SimpleDateFormat("yyyy-MM-dd").format(date);
System.out.println(time);
}
Try doing it with the help of SimpleDateFormat class or simply use Joda's LocalDate.
String dateInString= new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH).format(date);
System.out.println(dateInString);
Using Joda
System.out.println(LocalDate.now().toString("yyyy-MM-dd"));