java生成HTTP头中GMT时间格式的字符串

关于GMT时间,参见:
http://www.malaoshi.top/show_1EF1TS4sSI6v.html

导包:

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

代码:

SimpleDateFormat sdf = new SimpleDateFormat("EEE,d MMM yyyy HH:mm:ss z", Locale.ENGLISH);
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
String date = sdf.format(new Date());

原文出处:/show_1IX5qGcDS12O.html