Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:26:20+00:00 2026-05-29T22:26:20+00:00

i am try to parse string to date it works normally well but when

  • 0

i am try to parse string to date it works normally well but when i am use internationalization with &locate=fr then it will thrown java.lang.IllegalArgumentException.

hear is the peace of code i want to get date from string.

public static Date toDate(String date){
    DateTimeFormat format = DateTimeFormat.getFormat("MM/dd/yy h:mm:s a");
    return format.parseStrict(date);
}

and i am try to convert “02/02/2012 10:10:25 AM”.

please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:26:21+00:00Added an answer on May 29, 2026 at 10:26 pm

    Try using parse() instead of parseStrict(). If you use parse() dates are parsed leniently, so invalid dates will be wrapped around as needed. And with parseStrict() dates are parsed strictly, so invalid dates will result in an IllegalArgumentException. See you are using different format for your date.
    02/02/2012 which corresponds to MM/dd/yyyy not to MM/dd/yy

    public Date parseStrict(java.lang.String text) throws java.lang.IllegalArgumentException
    

    Parses text to produce a Date value. An IllegalArgumentException is
    thrown if either the text is empty or if the parse does not consume
    all characters of the text. Dates are parsed strictly, so invalid
    dates will result in an IllegalArgumentException.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm try to parse this xml, but c# keeps throwing an exception saying it
I have a method which parses a string in to a date, but i
I am trying to parse an SQL date string (ISO 9075) and that uses
I'm trying to read a date out of a text file then parse the
I have some code that tries to parse a date string. When I do
The codes: String[] logs={a,b,c}; int errors=0; for(String str:logs){ try{ LogParser.parse(str); } catch(ParseException e){ error++;
Hi i am trying to parse a string into a java.sql.date Here is what
I'm trying to parse string representation of date. It looks like 20120306 14:21:35 MSK
I'm implementing a TryParse(string s, Out object result) method. If the parse fails, I
I try to parse RSS chaanal with simple-rss lib. Unfortunately I got a lot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.