How to format a date String into desirable Date format

前端 未结 5 1072
南旧
南旧 2021-01-22 17:11

I was trying to format a string into date.

For this I have written a code:-

Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateF         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-22 17:54

    If your input is going to be ISO, you could also look at using the Joda Time API, like so:

    LocalDateTime localDateTime = new LocalDateTime("2010-10-22");
    System.out.println("Formatted time: " + localDateTime.toString());
    

提交回复
热议问题