我有一个像从时区转换-500时间到设备所在的时区
2016-12-26 02:54:20 -0500
格式的日期时间现在我需要这个时间转换为设备位于时间格式。 如果在新加坡使用的设备时间应该自动转换到新加坡时区,如果设备在印度然后自动转换到印度时区。 请帮助获得解决方案,在此先感谢。
我有一个像从时区转换-500时间到设备所在的时区
2016-12-26 02:54:20 -0500
格式的日期时间现在我需要这个时间转换为设备位于时间格式。 如果在新加坡使用的设备时间应该自动转换到新加坡时区,如果设备在印度然后自动转换到印度时区。 请帮助获得解决方案,在此先感谢。
使用此方法
public String convertTimeZone(String date) throws ParseException {
SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
inFormat.setTimeZone(TimeZone.getDefault());
Date toConvert = inFormat.parse(date);
date = inFormat.format(toConvert);
return date.toString();
}
好,这是在SQL时间格式? – xFighter
我不确定你在问什么。 – Bethan
你知道sql吗? – xFighter