查看当前服务器下的时间:〔rootswk204〕dateFriJan2519:28:28CST2019〔rootswk204〕dateYmdH:M:S2019012519:28:36〔rootswk204〕问题解决 设置操作系统的时区:〔rootengine〕tzselectPleaseidentifyalocationsothattimezonerulescanbesetcorrectly。Pleaseselectacontinentorocean。1)Africa2)Americas3)Antarctica4)ArcticOcean5)Asia6)AtlanticOcean7)Australia8)Europe9)IndianOcean10)PacificOcean11)noneIwanttospecifythetimezoneusingthePosixTZformat。?5Pleaseselectacountry。1)Afghanistan18)Israel35)Palestine2)Armenia19)Japan36)Philippines3)Azerbaijan20)Jordan37)Qatar4)Bahrain21)Kazakhstan38)Russia5)Bangladesh22)Korea(North)39)SaudiArabia6)Bhutan23)Korea(South)40)Singapore7)Brunei24)Kuwait41)SriLanka8)Cambodia25)Kyrgyzstan42)Syria9)China26)Laos43)Taiwan10)Cyprus27)Lebanon44)Tajikistan11)EastTimor28)Macau45)Thailand12)Georgia29)Malaysia46)Turkmenistan13)HongKong30)Mongolia47)UnitedArabEmirates14)India31)Myanmar(Burma)48)Uzbekistan15)Indonesia32)Nepal49)Vietnam16)Iran33)Oman50)Yemen17)Iraq34)Pakistan?9Pleaseselectoneofthefollowingtimezoneregions。1)eastChinaBeijing,Guangdong,Shanghai,etc。2)Heilongjiang(exceptMohe),Jilin3)centralChinaSichuan,Yunnan,Guangxi,Shaanxi,Guizhou,etc。4)mostofTibetXinjiang5)westTibetXinjiang?1Thefollowinginformationhasbeengiven:ChinaeastChinaBeijing,Guangdong,Shanghai,etc。ThereforeTZAsiaShanghaiwillbeused。Localtimeisnow:FriJan2515:10:18CST2019。UniversalTimeisnow:FriJan2507:10:18UTC2019。IstheaboveinformationOK?1)Yes2)No?1YoucanmakethischangepermanentforyourselfbyappendingthelineTZAsiaShanghai;exportTZtothefile。profileinyourhomedirectory;thenlogoutandloginagain。HereisthatTZvalueagain,thistimeonstandardoutputsothatyoucanusetheusrbintzselectcommandinshellscripts:AsiaShanghai〔rootengine〕调整时区文件到对应目录 备份当前的时区配置〔rootengine〕mvetclocaltimeetclocaltimeold 替换系统时区文件〔rootengine〕cpusrsharezoneinfoAsiaShanghaietclocaltime 或者创建链接文件〔rootengine〕lnsfusrsharezoneinfoAsiaShanghaietclocaltime 修改clock系统配置文件etcsysconfigclock为如下内容〔rootswk204〕catetcsysconfigclockZONEAsiaShanghaiUTCfalse设置为false,硬件时钟不于utc时间一致ARCfalse〔rootswk204〕 设置操作系统环境变量TZ 在etcprofile或。bashrc文件中设置环境变量TZexportTZAsiaShanghai 或者TZAsiaShanghai;exportTZ 通过source命令即可完成设置JAVA进程调整时区 AVA硬编码importjava。util。TimeZone;importjavax。annotation。PostConstruct;importorg。springframework。stereotype。Component;ComponentpublicclassTimeZoneStartup{设置时区PostConstructpublicvoidinit(){TimeZone。setDefault(TimeZone。getTimeZone(AsiaShanghai));}} 按照以上方法操作后,可以获取指定的时区