Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Converting String Date to DateTimePST(String) and DateTimeLocal(String) using Offset?

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried doing something like this


I am missing out seconds and this seems to be an inefficient way beacuse i do not need 'T' or offset in my output and i am getting rid of them. I am not sure if this question is already asked. Any help is appreciated.
Posts: 70709
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I presume you are parsing the strings into date‑time objects correctly, but why not find out about reading times with format objects. That would obviate the long lines, for one thing.
Classes like LocalDateTime have lots of methods some of which can get the individual fields so you can use them with System.out.printf("...%d...",...);
There are doubtless other ways to get a date formatted nicely: try the Java™ Tutorials.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic