Greenwich Mean Time (GMT) Origin
Because the earth's orbit is not circular and its operation speed changes with the distance between the Earth and the Sun, uniformity is lacking when the sun is regarded. The sun length is also affected by the tilt of the Earth's self-rotating shaft relative to the orbital plane. To correct the above non-uniformity, astronomers calculated the effect of the earth's non-circular trajectory and polar axis skew on the sun. Normal sun refers to the revised sun-watching time. The ordinary sun on the Greenwich meridian is called the Universal Time (ut0) and Greenwich Mean Time (GMT ).
Relationship between Beijing time and GMT time
GMT is the Central Time Zone. Beijing is located in the east 8 zone. The difference is 8 hours. Therefore, Beijing time = GMT time + 8 hours Greenwich Mean Time [Day] GMT Standard Time
Greenwich mean the standard time of the Royal Greenwich Observatory on the outskirts of London, as the meridian is defined as passing through it.
Theoretically, midday Greenwich mean the time when the Sun crosses the Greenwich Meridian. Because the earth's motion speed in its elliptical orbit is uneven, this time may be 16 minutes different from the actual sun time. The daily rotation of the earth is somewhat irregular and is slowing down slowly. Therefore, Greenwich Mean Time is no longer used as the standard time. The current standard time-Coordinated Universal Time (UTC)-is provided by an atomic clock.
Since January 1, February 5, 1924, the Greenwich Mean observatory will distribute Time-of-adjustment information to the world every hour.
Here is an example to illustrate how to convert to GMT. The GMT time is used on the HTTP header. If you want to set the last-modified parameter, how to construct the time format? Key points are as follows:
1. Available
SimpleDateFormat
Eee-three weeks
D-Day
Mmm-month
Yyyy-four-digit year
HH-24 hour message
Mm-min
SS-seconds
'Gmt'-GMT string. Do not forget to add single quotation marks.
With this mask, the date format required for the HTTP header can be constructed perfectly.
2. The file modification time is local time. If you want to convert the file time to GMT, you must add the time zone settings,
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Code
String sFile = "c:\\test.jpg";File file = new File(sFile);if(file.exists()){ long lm = file.lastModified(); Calendar cd = Calendar.getInstance(); cd.setTimeInMillis(lm); SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss 'GMT'", Locale.US); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); String timeStr = sdf.format(cd.getTime()); String timeStr = sdf.format(cd.getTime()); log.debug("lastModify=" + timeStr); }//...
3. Set locale. us because the output is Chinese Based on the machine's Localization settings. Only English is needed here. simpledateformat constructor is as follows:
SimpleDateFormat(String pattern, Locale locale)
Output result:
lastModify=Thu, 15 Sep 2011 12:13:41 GMT