In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "what is the time API in java". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "what is the time API in java" can help you solve the problem.
1. The Clock class can be used to access the current date and time. Clock can get the current time zone instead of System.currenttimeMillis ().
Clock clock = Clock.systemDefaultZone (); long millis = clock.millis (); Instant instant = clock.instant (); Date legacyDate = Date.from (instant); / / legacy java.util.Date
2. Time is expressed in zoneId, and zoneId can be accessed through a static factory.
System.out.println (ZoneId.getAvailableZoneIds ()); / / prints all available timezone ids ZoneId zone1 = ZoneId.of ("Europe/Berlin"); ZoneId zone2 = ZoneId.of ("Brazil/East"); System.out.println (zone1.getRules ()); System.out.println (zone2.getRules ()); / / ZoneRules [currentStandardOffset=+01:00] / / ZoneRules [currentStandardOffset =-03:00]
3. LocalTime means there is no time area, such as 10pm or 17:30:15.
LocalTime now1 = LocalTime.now (zone1); LocalTime now2 = LocalTime.now (zone2); System.out.println (now1.isBefore (now2)); / / false long hoursBetween = ChronoUnit.HOURS.between (now1, now2); long minutesBetween = ChronoUnit.MINUTES.between (now1, now2); System.out.println (hoursBetween); / /-3System.out.println (minutesBetween); / /-239 this is the end of the introduction of "what is time API in java". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.