简体   繁体   English

Android:日期到日期格式的字符串

[英]Android: String of date to Date format

I have a string : "2012-08-10" which represents : "yyyy-MM-dd" 我有一个字符串:“2012-08-10”代表:“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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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