我需要将字符串日期格式转换为utc,我尝试转换如下,但它不能正常工作不知道我做了什么错误
String str_date = "03-06-2015 00:00:00";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date;
try {
date = df.parse(dateStr);
stratingdate = df.format(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LogUtil.d("starting date" + stratingdate);
所以请帮我找出问题
答案 0 :(得分:0)
简单日期Formate,它接受格式如03/04/2015 00:00:00,它已成功运行..
String str_date = "03/06/2015 00:00:00";
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date;
try {
date = df.parse(str_date);
stratingdate = df.format(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LogUtil.d("starting date" + stratingdate);