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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:42:37+00:00 2026-06-17T21:42:37+00:00

I am trying to format a date with Joda time library but my problem

  • 0

I am trying to format a date with Joda time library but my problem is that it behaves different depending in which device it is executed. This is my code:

public static String parseDate (String date)
{
    final String datePattern = "yyyy-MM-dd, ";
    final String hourPattern = "HH:mm";

    DateTimeParser[] parsers = { 
            DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss Z").getParser(),
            DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss ZZZ").getParser(),
            DateTimeFormat.forPattern("yyy-MM-dd'T'HH:mm:ss.SSSZ").getParser()};

    DateTimeFormatter formatter = new DateTimeFormatterBuilder().append( null, parsers).toFormatter();

    String daux = "";
    try
    {
        DateTime dt = formatter.parseDateTime(date);
        String pubDate = dt.toString(datePattern);
        String pubHour = dt.toString(hourPattern);
        daux = pubDate + "kl " + pubHour;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

    return daux;
}

The date “Tue, 24 Apr 2012 11:06:19 GMT” it is formatted correctly in a nexus 4 but it raises an exception when executed in a Samsung GS2. I dont know really what it could be.

The exception is:

01-22 15:21:05.160: W/System.err(11718): java.lang.IllegalArgumentException: Invalid format: "Sun, 20 Jan 2013 23:27:00 GMT"
01-22 15:21:05.160: W/System.err(11718):    at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:866)
01-22 15:21:05.160: W/System.err(11718):    at com.fotbollskanalen.parser.DateParser.parseDate(DateParser.java:150)

Any ideas?

  • 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-06-17T21:42:38+00:00Added an answer on June 17, 2026 at 9:42 pm

    You’re likely facing locale specific issues in parsing.

    From DateTimeFormatter.forPattern() javadoc:

    The format may contain locale specific output, and this will change as you change the locale of the formatter. Call DateTimeFormatter.withLocale(Locale) to switch the locale. For example:

    DateTimeFormat.forPattern(pattern).withLocale(Locale.FRANCE).print(dt);

    UPD

    You should change the line to:

    DateTimeFormatter formatter = new DateTimeFormatterBuilder().append( null, parsers).toFormatter().withLocale(Locale.ENGLISH);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to format a date into required format. but i receive wrong
I am trying to format a date: FORMAT(table.TCKT.TCKT_ISS_DATE, 'YYYY') AS TICKETYEAR but I am
I'm trying to format a date in Java in different ways based on the
I am trying to convert date which is in string and got format of
I am trying to format a string into specific date format but there is
Hello I have been trying to format this date but it keeps giving me
I'm trying to format a date to say how much time is left (in
Trying to convert date to specific format but getting error: <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
I'm am trying to format a date in Javascript but the date command is
I'm trying to format the date and time on my app based on the

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.