Hi, 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.