Win a flower (🌹) or copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java (📚) this week in the Agile and Other Processes 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
master stewards:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
garden masters:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
gardeners:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Help in converting date from string

 
pioneer
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I try to convert a String into milliseconds but it seems that I am using the wrong pattern.




I'm still getting the same ParseException
 
garden master
Posts: 11467
247
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is probably that the default locale can't make sense of "Mon". You can try constructing your format with Locale.ENGLISH.
 
master steward
Posts: 21865
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always see at what index of the String the exception occurs by checking the ParseException's error offset:
In this case it fails because German expect "Mo", not "Mon". My default locale has no problems at all.
 
Alessandro Camel
pioneer
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:The problem is probably that the default locale can't make sense of "Mon". You can try constructing your format with Locale.ENGLISH.



You are right!
Using :



everything is working!

Thanks!
 
Marshal
Posts: 68014
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The German for Monday is Montag, so maybe the problem is Dec, which would be Dez for Dezember in German
 
Stephan van Hulst
garden master
Posts: 11467
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, but I think Alessandro is using Portuguese :P
 
Campbell Ritchie
Marshal
Posts: 68014
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could have sworn somebody was using German. Oh yes, it’s Rob. That got me totally confused. Sorry.
 
Rob Spoor
master steward
Posts: 21865
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was the first supported (as in: it is a static field of Locale), non-English locale I could think of
 
Do you want ants? Because that's how you get ants. And a tiny ads:
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!