Printing out datetime in a specific format in Java?

后端 未结 4 1261
抹茶落季
抹茶落季 2020-12-02 00:58

I want to print out datetime in java in a specific format. I have this C# code which prints out the datetime in this format.

DateTime value = new DateTime(2         


        
4条回答
  •  醉梦人生
    2020-12-02 01:35

    LocalDate.of(2010, 1, 18).atStartOfDay().format(DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss a"))
    

    or

    LocalDate.of(2010, 1, 18).atTime(12, 0, 0).format(DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss a"));
    

    if you want to add the time too

提交回复
热议问题