ParseException in JFreeChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Valfran

ParseException in JFreeChart

Post by Valfran » Tue Nov 05, 2002 12:27 pm

I have installed JFreeChart War sample in my server (TomCat - j2sdkee1.3.1) and when I go to any page of chart I get the following error:

java.Text.ParseException: Unparseable date: "01-Aug-2002"

What it could be?


Thanks All

Richard Atkinson

Re: ParseException in JFreeChart

Post by Richard Atkinson » Tue Nov 05, 2002 1:02 pm

A couple of people have reported problem with the WAR file when running in different locales. I cannot currently replicate the problem on my machine. Do you have a full stack trace? Alternatively could you try running the following code and see if it produces a stack trace.

import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException;

public class DateTest {

public static void main(java.lang.String[] args) {

SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
Date dDate = null;

try {
dDate = sdf.parse("01-Aug-2002");
System.out.println("Date - " + dDate.toString());
} catch (ParseException e) {
e.printStackTrace();
}

}

}

Thanks and regards,
Richard...

Valfran

Re: ParseException in JFreeChart

Post by Valfran » Tue Nov 05, 2002 1:18 pm

Richard,

This code really produced the same error! And it happens in class WedHitDataSet, line 26. Im running JDK 1.3.1 and my OS is Winnt english version.
I wil continue the tests here. If you could give me a tip, Thanks a lot!

Valfran

Richard Atkinson

Re: ParseException in JFreeChart

Post by Richard Atkinson » Tue Nov 05, 2002 2:54 pm

Valfran,

Could you try the following code for me. I think the exception is happening because different symbols are being used with your default locale.

Thanks and regards,
Richard...

import java.util.Date;
import java.util.Locale;
import java.text.SimpleDateFormat;
import java.text.ParseException;

public class DateTest {

public static void main(java.lang.String[] args) {

SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
Date dDate = null;

try {
dDate = sdf.parse("01-Aug-2002");
System.out.println("Date - " + dDate.toString());
} catch (ParseException e) {
e.printStackTrace();
}

}

}

Valfran

Re: ParseException in JFreeChart

Post by Valfran » Tue Nov 05, 2002 4:53 pm

Richard

Now it works! I was using Portuguese Brazilian regional configuration! But defining locale in the code it works fine!

I will add this code in the JFreeChart (WebHitDataSet) class too!

Thank you very much for the help!

Valfran

Richard Atkinson

Re: ParseException in JFreeChart

Post by Richard Atkinson » Tue Nov 05, 2002 5:03 pm

Valfran,

Great, glad it works for you. Thanks for your help in testing it out.
I'll update the WAR file on my web site this evening with the changes.

Regards,
Richard...

Richard Atkinson

Re: ParseException in JFreeChart

Post by Richard Atkinson » Tue Nov 05, 2002 9:31 pm

I have updated the WAR file at http://homepage.ntlworld.com/richard_c_ ... freechart/.

The sample WAR should now work correctly for default Locates that have different DateFormat symbols to the UK/US.

Regards,
Richard...

Locked