I have a date variable
var date: Date = new Date()
then I have converted this date to String:
var dateStr = date.toString()
now I need to convert back this String to date.
I have tried both:
1:
var stringToDate: Date = date2Str.asInstanceOf[Date]
and 2:
stringToDate: Date = new SimpleDateFormat("dd.MM.yyyy").parse(dateStr);
But in both case I got the error:
java.lang.ClassCastException:
java.lang.String cannot be cast to java.util.Date
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…