2

I want to change the format of the date which I entered using date picker

i want to change it dd-mm-yyyy but now it's in mm/dd/yyyy

yole
  • 87,251
  • 17
  • 245
  • 186

2 Answers2

2

If you have date as string, use this to convert in date and then format it

 String sDate1="03/08/1993";  
 Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(sDate1);  

Use this

String pattern = "dd-MM-yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);

String date = simpleDateFormat.format(date1);
System.out.println(date);

to format date in any format

Ravi
  • 729
  • 7
  • 21
0

Simply use the following lines of code:

$(".datepicker").datepicker({
    dateFormat: "dd-mm-yy",     
});

In fact, yy serves the purpose of yyyy here.

sarwar026
  • 3,773
  • 3
  • 25
  • 36