Format date in Java

后端 未结 4 827
醉酒成梦
醉酒成梦 2020-12-19 15:10

I have the following string:

Mon Sep 14 15:24:40 UTC 2009

I need to format it into a string like this:

14/9/2009

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 15:54

    Date d = new Date("Mon Sep 14 15:24:40 UTC 2009");
    SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy");
    String s = new String(f.format(d));
    

提交回复
热议问题