
Exception in thread "main"
java.time.zone.ZoneRulesException: Unknown time-zone ID: America/NewYork
at java.base/java.time.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:279)
at java.base/java.time.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:234)
at java.base/java.time.ZoneRegion.ofId(ZoneRegion.java:120)
at java.base/java.time.ZoneId.of(ZoneId.java:408)
at java.base/java.time.ZoneId.of(ZoneId.java:356)
at org.code2care.Java8AddDaysToDate.main(Java8AddDaysToDate.java:18)
If you get ZoneRulesException runtime exception with message Unknown time-zone ID, that's because you have passed the unknown or incorrect city/country timezone string.
Instant now = Instant.now();
ZonedDateTime zdt = ZonedDateTime.ofInstant(now, ZoneId.of("America/NewYork"));
System.out.println(zdt);
Fix:
In the above example, the NewYork string should be New_York
Instant now = Instant.now();
ZonedDateTime zdt = ZonedDateTime.ofInstant(now, ZoneId.of("America/New_York"));
System.out.println(zdt);
List of Time-Zone ID Strings: https://code2care.org/pages/java-timezone-list-utc-gmt-offset
More Posts related to Java,
- How to install Java 11 on Mac
- Get Client IP address from HTTP Response in Java
- SharePoint Open in the client application document opens in browser
- How to verify if java is installed on the computer and get version detail
- Java - Check if array contains the value
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console
- How to run Java Unit Test cases with Apache Maven?
- What Java version is used for Minecraft 1.18
- List of jar files for Jax-ws (SOAP) based Java Web Services
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- Convert Instant timestamp into LocalDateTime Java Code Example
- Java - Calculate time taken for the code to execute in milliseconds or nanoseconds
- Create simple struts2 project using maven commands
- Java - PatternSyntaxException
- List of Online Java compiler with console
- Minecraft Java Edition
- How to declare and initialize Array in Java Programming
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- Java XML-RPC 3.1.x based web service example
- Simple Struts 2 Tutorial in eclipse with tomcat 7 server
- Java 8 foreach loop code examples
- Java -Day of the week using Java 8 DayOfWeek Enum
- Java 8 - Convert List to Map Examples
- Java: TimeZone List with GMT/UTC Offset
- list of jars required for hibernate 4.x.x
More Posts:
- Eclipse : This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in - Eclipse
- WARNING: Python 2.7 is not recommended [macOS Big Sur] - MacOS
- How to clear cache and browsing history in Google Chrome? - Chrome
- How to activate and create SharePoint Spaces feature for mixed reality experience - 2D/3D images and web parts - SharePoint
- java.lang.ClassNotFoundException android.support.v7.widget.Toolbar [Fix] - Android