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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:04:02+00:00 2026-05-12T17:04:02+00:00

so I was having a problem parsing a date, using the JodaTime chronology IslamicChronology

  • 0

so I was having a problem parsing a date, using the JodaTime chronology IslamicChronology so wrote a small example to demonstrate my problem.

Here’s the code:

import org.joda.time.Chronology;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.chrono.IslamicChronology;

import java.util.Date;

/**
 * Test
 */
public class Test
{
    public static void main(String[] args)
    {
        Date now = new Date();

        String format = "dd MMM yyyy";
        Chronology calendarSystem = IslamicChronology.getInstance();
        DateTimeFormatter formatter = DateTimeFormat.forPattern(format).withChronology(calendarSystem);

        String nowAsString = formatter.print(now.getTime());

        System.out.println("nowAsString = " + nowAsString);

        long parsedNowTs = formatter.parseMillis(nowAsString);

        String parsedNowTsAsString = formatter.print(parsedNowTs);
    }
}

And the output:

nowAsString = 16 10 1430
Exception in thread "main" java.lang.IllegalArgumentException: Invalid format: "16 10 1430" is malformed at "10 1430"
    at org.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:634)
    at test.Test.main(Test.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    ...

I’m thinking the problem is that the month name is numeric but am I right? Anyone got any suggestions? This cannot be recreated if the chronology is gregorian.

Thanks in advance.

  • 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-12T17:04:02+00:00Added an answer on May 12, 2026 at 5:04 pm

    If anyone’s interested…I’ve found a work around:

    • Create a new class e.g. IslamicChronologyWithNames which delegates to an instance of IslamicChronology in package org.joda.time.DateTimeZone
    • Modify the one method; assemble(Fields fields): call the delegate’s method and then set fields.monthOfYear (and possibly dayOfWeek) to you own subclass of BasicMonthOfYearDateTimeField
    • The subclass of BasicMonthOfYearDateTimeField can then lookup in property files names for the month’s (or day’s if DayOfWeek…) name. Subclass needs to be in package org.joda.time.chrono to be able to extend BasicMonthOfYearDateTimeField.

    There is still an issue that Joda time seems to validate the date you are parsing before calling methods of subclass like getAsText(int fieldValue, Locale locale) and because it has no knowledge of the month names that your class returns, fails validation and so never calls the methods. My work-around was to have a static method in this class which converts a date as a string with islamic month names into a date as a string with gregorian english month names. So before calling parseDateTime(), call the static method and then the date string passes validation. Then, instead of processing Islamic month names in the convertText() method, use the default gregorian implementation inside your subclass:

    protected int convertText(String text, Locale locale)
    {
        return GJLocaleSymbols.forLocale(locale).monthOfYearTextToValue(text);
    }
    

    That should work! Hope it makes sense for anyone who has the same problem.

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

Sidebar

Related Questions

Having a problem with parsing Snort logs using the pyparsing module. The problem is
I'm writing a small web server, and having a problem with parsing a request.
Having a problem with parsing a CSV file. I connect to the file using
I am having problem in parsing the xml data, below is my code URL
I'm having a problem with parsing XML in Android app, a question here implies
I'm having problem parsing the Date from an input string that is of the
I am having a problem handling date variables when I write to PostgreSQL using
Am having a problem reading/parsing the following JSON string in Java. Code: try{ json
I'm having a problem parsing my parameters in ASP.Net Here's what i'm doing Sub
I'm having a problem parsing a JSON file in AS3. Im trying to parse

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.