我想从日期从JSON格式转换为我的本地时间。通过使用SimpleDateFormat没有得到适当的时间
我得到的时间为10/27/2013 5:58:02 PM
,我需要转换为我的当地时间,这是+5:30
。
但是,我得到10/27/2013 6:28:02
。
我的代码是
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("M/d/yyyy H:mm:ss a");
SimpleDateFormat longDateFormat=new SimpleDateFormat("M/d/yyyy H:mm:ss");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String formattedDate="";
try
{
Date myDate = simpleDateFormat.parse(mDateAndTime);
formattedDate = longDateFormat.format(myDate);
} catch (ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
如果删除线... simpleDateFormat.setTimeZone(TimeZone.getTimeZone( “UTC”)); 可能是有效的。我不确定,因为我无法测试它。请尝试 –
thnx的回复,但我越来越10/27/2013 0:58:02 –