android将日期字符串转换为以毫秒为单位的时间
早上好 我将此日期作为字符串:android将日期字符串转换为以毫秒为单位的时间,android,date,datetime,Android,Date,Datetime,早上好 我将此日期作为字符串: 2016-05-20 00:00:00 现在我想将这个字符串转换为日期格式,并转换为毫秒 我试过这个: SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); Date convertedDate = new Date(); try { convertedDate = dateFormat.parse(c1.getString(c1.getColumnI
2016-05-20 00:00:00
现在我想将这个字符串转换为日期格式,并转换为毫秒
我试过这个:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
Date convertedDate = new Date();
try {
convertedDate = dateFormat.parse(c1.getString(c1.getColumnIndex(DatabaseHelper.COLUMN_MHD)));
} catch (ParseException e) {
e.printStackTrace();
}
2016年1月20日星期三00:00:00墨西哥中部
但是现在如何将该日期转换为毫秒呢?使用MM表示月份
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
并得到时间使用方法
有关更多信息,请查看ahhh这是我的错误。我尝试了convertedDate.getTime()-但该值不能是正确的值。但是对于MM,它工作得很好!。谢谢:)
long timeInMilliseconds = convertedDate .getTime();
Log.d("time in millisecond",""+timeInMilliseconds );