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

后端 未结 10 1268
南旧
南旧 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:21

    You can't - because you're calling Date.toString() which will always include the system time zone if that's in the default date format for the default locale. The Date value itself has no concept of a format. If you want to format it in a particular way, use SimpleDateFormat.format()... using Date.toString() is almost always a bad idea.

提交回复
热议问题