Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

While parsing DatTime in french language am getting illegalArguemtException

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String dateStr="Aug 4,2022 11:48:40";

DateTimeFormatter dtfTx = DateTimeFormat.forPattern("MMM d,yyyy H:m:s").withLocale(Loocal.FRENCH);

System.out.print("dtfTx" +dtfTx.parseDateTime(dateStr).getMillis());


while parsing am getting below issues:


Exception in thread "main" java.lang.IllegalArgumentException: Invalid format: "Aug 4,2022 11:48:40"
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:945)
at com.cat.ngsite.DateFormatTesting.main(DateFormatTesting.java:56)

Please help me how to solve this issue in french language
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please copy the exact text of the source code and paste it here.  
The posted code has compiler errors and can not be compiled for testing.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm guessing that will be because the French name for the eighth month of the year is Aout, so Aug is not a valid abbreviation!
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Baktha Elumalai wrote: at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:945)



Also, it looks like you've imported JodaTime. That was a package which was designed to replace the bad old java.util.Date class and its relatives by properly architected Java code. It worked very well for that but the date-time-calendar code which has been in Java since Java 8 was adapted from that. So there's no reason to use JodaTime any more (unless you haven't managed to move up to Java 8 yet).
 
Marshal
Posts: 79530
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Baktha Elumalai wrote:. . . DateTimeFormatter dtfTx . . .

Also, please choose legible and pronounceable names for your variables.
 
On my planet I'm considered quite beautiful. Thanks to the poetry in this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic