Код: Выделить всё
public Date getStartDate() {
try {
System.out.println("startDate" + startDate); // prints Fri Jan 02 00:00:00 EST 1998
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String today = formatter.format(startDate);
System.out.println("today" + today); // prints 02-01-1998 00:00:00 (I need to return Date object in this format)
DateFormat formatter2 = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
Date reformatedDate = formatter2.parse(today);
System.out.println("reformatedDate" + reformatedDate); // Fri Jan 02 00:00:00 EST 1998
return reformatedDate;
} catch (Exception e) {
}
return null;
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... yyyy-hhmms