简体   繁体   中英

Can I change the format of date which entered using Local date?

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

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

Simply use the following lines of code:

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

In fact, yy serves the purpose of yyyy here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM