Date conversion

前端 未结 4 1295
失恋的感觉
失恋的感觉 2020-12-13 03:05

I have a date variable

var date: Date = new Date()

then I have converted this date to String:

var dateStr = date.toString(         


        
4条回答
  •  遥遥无期
    2020-12-13 03:08

    Your first try should give you a ClassCastException because you cannot cast.aString to a Date. the second try does not seem to be using the right format that Date.toString() prints. The toString method of java.utility.Date returns a String in the format specified in the javadoc.

提交回复
热议问题