• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Fun Times with DateTime Conversion

 
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Been racking my brain on this too long and I need some fresh perspective please.

I am trying to convert dates / times that are given to me like this: Thursday, January 25, 2018 at 3:50pm PST in to a MySQL Timestamp.

I've been trying to use JodaTime to do this conversion but i don't really care what I use as long as I can get it converted - which means if you have an alternate method to show me, please do.

Here is the code that I've been trying to accomplish this with:


When I execute this code, the compiler throws an Exception that looks like this:

Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Invalid format: "Thursday, January 25, 2018 at 3:50pm PST" is malformed at " 25, 2018 at 3:50pm PST"

and its pointing to this line as the source of the exception:

DateTime  dt = fmt.parseDateTime(date);

I've tried massaging the pattern with no luck for many hours... can someone see what I am doing wrong?

Thank you,

Mike Sims
 
Saloon Keeper
Posts: 12142
258
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well yeah, you have an extra comma in the format string after the month specifier.
 
Michael D Sims
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Well yeah, you have an extra comma in the format string after the month specifier.


MAN!!! Im so glad I posted this I would have continued overlooking that for god knows how long.

THANK YOU, it works now.
 
Stephan van Hulst
Saloon Keeper
Posts: 12142
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To my regret, I'm very VERY familiar with these kinds of d'oh moments.
 
Michael D Sims
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:To my regret, I'm very VERY familiar with these kinds of d'oh moments.


When I realized my efforts were not giving me success when I knew it should be working, I realized my head was too fuzzy and that a fresh pair of eyes would be bound to see it. This s why these forums are awesome!  

 
Marshal
Posts: 25677
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:To my regret, I'm very VERY familiar with these kinds of d'oh moments.



Probably the word "D'oh" wasn't invented specifically for computer programmers, but we certainly make good use of it.
 
Marshal
Posts: 69810
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:. . . Probably the word "D'oh" wasn't invented specifically for computer programmers . . .

Are you telling me Homer Simpson didn't invent it himself?
 
Michael D Sims
Ranch Hand
Posts: 167
1
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Paul Clapham wrote:. . . Probably the word "D'oh" wasn't invented specifically for computer programmers . . .

Are you telling me Homer Simpson didn't invent it himself?


I watched a documentary on this and some very credible Area 51 "researchers" presented a good case for this ... BUT ... as per usual ... no definitive, clear cut evidence ever emerges...

 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic