UTC (Universal Coordinated Time)/GMT (Greenwich Mean Time)/CST (Beijing Time)

About time format 2016-08-9T10:01:54.123Z 20160809100154.123Z processing method

I encountered a strange time format today

As shown in the following format, the time represented by the following two time formats is the same time. This is not difficult to understand.

//UTC时间,世界标准时间
2016-08-9T10:01:54.123Z 

20160809100154.123Z

As shown in the picture, this is a picture provided by a netizen, which shows the time

Convert UTC time to GSM time
UTC time to GSM time

And no matter what, we may not be able to understand this strange time, but the time we ultimately want to display is Beijing time (if you are from other countries, it is a different matter)

So let’s briefly introduce some basic knowledge about time:

First is UTC: Coordinated Universal Time

Coordinated Universal Time (English: Coordinated Universal Time, French: Temps Universel Coordonné), also known as Universal Unified Time, World Standard Time , International Coordinated Time. The English (CUT) and French (TUC) abbreviations are different, and as a compromise, the abbreviation is UTC.
Universal Coordinated Time UTC: GMT+0

GMT: Greenwich mean time

Universal Time UT is Greenwich Time, the standard time in the location of Greenwich. A time measurement system based on the Earth's rotation. The angle of the Earth's rotation can be measured by the movement of the local meridian relative to fundamental reference points on the Earth. In order to measure the rotation of the earth, people select two basic reference points on the earth: the vernal equinox (see equinox) and the sun. The times determined thereby are called sidereal time and solar time respectively.
However, the local time in Greenwich is one hour higher than the usual time in Greenwich, which is the local time in Greenwich: GMT+1

CST time: that is, Beijing time

Usually the time we store in the database or show to users is CST time.
Beijing time CST: GMT+8

Now let’s talk about the time above

2016-08-9T10:01:54.123Z

20160809100154.123Z

First the letter T: it represents the time that follows

The Z at the end represents UTC unified time

As for the millisecond represented by 123, you can test changing 123 to 1230. The final time will be increased by 1 second.

Such as the first expression above 2016-08-9T10:01:54.123Z

We can get a CST (Beijing time) time like this, see the following code:

String str ="2016-08-9T10:01:54.123Z";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
Date d = format.parse(str.replace("Z", " UTC"));//注意是空格+UTC
System.out.println(d);

This way we get a local time

The final time we got was: Tue Aug 09 18:01:54 CST 2016

And the expression 20160809100154.123Z

His conversion method is also the same. When formatting knowledge, just modify the format string as follows: yyyyMMddHHmmss.SSS Z

The time zone for Beijing time: UTC/GMT +8 and
the time zone for Greenwich mean time: UTC/GMT +1

Greenwich Mean Time Format:
Thu Oct 16 07:13:48 GMT 2015

Guess you like

Origin blog.csdn.net/asd54090/article/details/94721796