want current date and time in “dd/MM/yyyy HH:mm:ss.SS” format

后端 未结 10 1466
南旧
南旧 2020-11-22 01:31

I am using following code to get date in \"dd/MM/yyyy HH:mm:ss.SS\" format.

    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import          


        
10条回答
  •  情书的邮戳
    2020-11-22 02:15

    The output in your first printline is using your formatter. The output in your second (the date created from your parsed string) is output using Date#toString which formats according to its own rules. That is, you're not using a formatter.

    The rules are as per what you're seeing and described here: http://docs.oracle.com/javase/6/docs/api/java/util/Date.html#toString()

提交回复
热议问题