简体   繁体   中英

Android: String of date to Date format

I have a string : "2012-08-10" which represents : "yyyy-MM-dd"

I have tried to convert it to a date format using the following:

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 
 Date convertedDate = dateFormat.parse(eventDates.get(i));

However the log gives the following types of dates:

Fri Aug 10 00:00:00 GMT+01:00 2012

What am I doing wrong?

这是正确的,你的日志使用自己的日期表示,如果你想要相同的格式,那么你需要使用

dateFormat.format(dateInstance);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM