In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces MySQL to save time information on the simple method, the content of the article is carefully selected and edited by the author, with a certain pertinence, for everyone's reference significance is still relatively great, the following with the author to understand the MySQL save time information on the simple method.
The solution reference is as follows, that is, based on the SimpleDateFormat object, you need to be clear about the time zone that you currently need to use.
SimpleDateFormat.setTimeZone (TimeZone)
/ / Java:long timeMs = System.currentTimeMillis (); System.out.println ("long =" + timeMs); / / current time zoneSimpleDateFormat default = new SimpleDateFormat ("yyyy-MM-dd HH:mm"); System.out.println (default.format (timeMs)); / / + 8:00 time zoneSimpleDateFormat chinaFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm"); chinaFormat.setTimeZone (TimeZone.getTimeZone ("GMT+8:00")); System.out.println ("GMT+8:00 =" + chinaFormat.format (timeMs)) / / + 5:30 time zoneSimpleDateFormat indiaFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm"); indiaFormat.setTimeZone (TimeZone.getTimeZone ("GMT+5:30")); System.out.println ("GMT+5:30 =" + indiaFormat.format (timeMs))
Using the above method can actually solve the time zone problem, because I obtained the statistics through the hour table and the hour table is one record per hour. While the Indian time zone is GMT+5:30, there will be a half-hour data deviation on the basis of the current table structure, so in order to solve this problem, we modify the statistical granularity of the hour table to half an hour.
Summary:
The blog simply states the key solution to the time zone, and the premise of using this solution is that the international timestamp is stored in the database!
Only time storage based on absolute timestamp, there is no time zone problem at all! Time zone is just a display problem!
After reading the above simple methods of saving time information on MySQL, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.