[英]GMT date and time to convert Local device Date Time?
hi I got web service result 6/26/2013 12:00:00 AM from GMT how to make convert to local device time.Please give me solution 嗨,我从GMT获得了6/26/2013 12:00:00 AM的网络服务结果,如何将其转换为本地设备时间。请给我解决方案
I have implement this code but not working 我已经实现了此代码,但无法正常工作
public static String DateTime(Date date) {
SimpleDateFormat dateformat = new SimpleDateFormat("MM/dd/yyyy hh:mm a");
return dateformat.format(date);
}
Set the timezone to your formatter before parsing the date. 在解析日期之前,将时区设置为格式化程序。
public static String DateTime(Date date) {
SimpleDateFormat dateformat = new SimpleDateFormat("MM/dd/yyyy hh:mm a");
TimeZone tz = TimeZone.getDefault(); //Will return your device current time zone
dateformat.setTimeZone(tz); //Set the time zone to your simple date formatter
return dateformat.format(date);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.