时间格式的转换(得到时间的HTTP-GMT格式字符串)
在写程序的时候,不可避免的需要对时间进行处理,其中就包含需要将时间转换为GMT格式,以下是一种实现方式
//得到时间的HTTP-GMT格式字符串: (Wed, 15 Nov 1995 06:25:24 GMT)
public static String long2gmt(long time){
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String timeStr = sdf.format(time);
return timeStr;
}