• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Converting a UTC datetime to other time zones with java.time

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a date with UTC format, like this: 2019-09-05T11:22:01Z  That I need to convert to other timezones. java.time looks like it has all I need, but I'm having trouble using it. I've even used examples that I've found.

Here is one try, just trying to use java.time



But this gives me an error. What ridiculously obvkous thing am I doing wrong here?

 
Master Rancher
Posts: 3719
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've imported java.time.*, but that includes only the files in package java.time.  It does not include sub-packages.  So since DateTimeFormatter is in java.time.format, you need to add

or
 
Ben Warrick
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Simmons wrote:You've imported java.time.*, but that includes only the files in package java.time.  It does not include sub-packages.  So since DateTimeFormatter is in java.time.format, you need to add

or



Thanks Mike...

So this is pretty straight forward.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic