I am new to Java. Postgres db contain date format is yyyy-MM-dd
. I need to convert to dd-MM-yyyy
.
I have tried this, but wrong result is display
public static void main(String[] args) throws ParseException {
String strDate = "2013-02-21";
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
Date da = (Date)formatter.parse(strDate);
System.out.println("==Date is ==" + da);
String strDateTime = formatter.format(da);
System.out.println("==String date is : " + strDateTime);
}
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat format2 = new SimpleDateFormat("dd-MM-yyyy");
Date date = format1.parse("2013-02-21");
System.out.println(format2.format(date));