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 7404955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:19:50+00:00 2026-05-29T05:19:50+00:00

I have to parse a String to a Date object in Java. The string

  • 0

I have to parse a String to a Date object in Java.
The string I get following the pattern MMM d yyyy HH:mm:ss z with locale set to French.

The problem occures when the date is in february, august or december due to encoding of french accents. For example, I get déc. 15 2011 16:55:38 CET for december 15th 2011.

I can’t change the way the string is created so I have to deal with the bad encoding on my side. It seems that when generated the string is badly encoded (UTF-8 content encoded as ISO 8859-1) then escapde.

For now I use :

stringFromXML = stringFromXML.replaceAll("é", "é");
stringFromXML = stringFromXML.replaceAll("û", "û");

It works because the only accent in french month are é and û but is there a cleaner way to unescape and convert characters?

  • 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-29T05:19:50+00:00Added an answer on May 29, 2026 at 5:19 am

    You need two steps:

    1. Resolve numeric character references, for example, using StringEscapeUtils as suggested by Andy:

      String unescaped = StringEscapeUtils.unescapeHtml(in);
      
    2. Fix encoding by treating characters as UTF-8 code units:

      String out = new String(unescaped.getBytes("ISO-8859-1"), "UTF-8");
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string Tue Nov 12 2010,I want to parse it in java.util.Date object.
I have the following method to convert a String to Date object public Date
I have this string containing a date I need to parse to get a
I have a date string and I want to parse it to normal date
I have parsed a java.util.Date from a String but it is setting the local
I have this date object: SimpleDateFormat df = new SimpleDateFormat(yyyy-mm-dd HH:mm); Date d1 =
I have javascript date object which gives me a date string in this format,
I have a datetime string being provided to me in the following format: yyyy-MM-dd
I have following string. DATE: 12242010Key Type: Nod32 Anti-Vir (30d trial) Key: a5B2s-sH12B-hgtY3-io87N-srg98-KLMNO I
I have the following JSON text to parse in Java: { items: [ {

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.