Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Parsing date

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is there any way to parse following string in a Date object in Java?

2020-01-14T00:54:42.2837Z

I tried to parse it using "yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'" format but it didn't work.

Thanks for your help!
 
Saloon Keeper
Posts: 6940
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use LocalDateTime. I'm assuming you're not interested in time zones because the format you show doesn't support it).

 
Rancher
Posts: 4493
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though Carey has shown how to di the parsing, one thing I will say is that "it doesn't work" is not much use to us.
You need to show us the problem code, and what exactly is going wrong, that way we can help with any misunderstandings you may have with how the code is supposed to work.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think LocalDateTime use would solve your problem.
 
Bartender
Posts: 21758
148
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carey Brown wrote:Use LocalDateTime. I'm assuming you're not interested in time zones because the format you show doesn't support it).



Well, actually, the "Z" at the end is the time zone (Zulu, which is GMT).
 
A feeble attempt to tell you about our stuff that makes us money
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!