I need date format in dd-mm-yyyy
format in jsp.My database
(dd/mm/yyyy-having date datatype in db) is read to jsp(using form bean, CmFrm.getExpireDate() - having datatype as string).
It is now read as yyyy-mm-dd hh:mm:ss.a
in jsp i want it to read in dd-mm-yyyy
format.
I have tried using --
String txtdate =CmFrm.getExpireDate();
SimpleDateFormat pd = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date = (Date) pd.parse(txtdate);
String DisplayDate= df.format(date);
System.out.println("MyExpireDate.."+DisplayDate);
I get unparsable
error.
I have applied format function alone as -
String txtdate =CmFrm.getExpireDate();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
System.out.println("Date.."+df.format(txtdate));
here jsp goes blank
.
please help as how to display date on jsp in dd-mm-yyyy
.
I tried your first code and I don't get any exceptions:
When I execute the following, I get:
Maybe you've imported the wrong date libraries? I imported these:
Should do you good...
Output example: 2016-11-19