android本地时间转成转成格林威治时间 java本地时间转成转成格林威治时间

来源:互联网 发布:jquery高级编程 编辑:程序博客网 时间:2024/04/26 05:51
/***
* 转成格林威治时间

* @param LocalDate           2015-03-23  12:12:12
* @return
*/
private String LocalToGTM("2015-03-23  12:12:12") {


SimpleDateFormat format;
format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
Date result_date;
long result_time = 0;


if (null == LocalDate) {
return LocalDate;
} else {
try {
format.setTimeZone(TimeZone.getDefault());
result_date = format.parse(LocalDate);
result_time = result_date.getTime();
format.setTimeZone(TimeZone.getTimeZone("GMT00:00"));
return format.format(result_time);
} catch (Exception e) {
e.printStackTrace();
}
}
return LocalDate;


}
0 0
原创粉丝点击