We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › SimpleDateFormat Problem
Page Index Toggle Pages: 1
SimpleDateFormat Problem (Read 798 times)
SimpleDateFormat Problem
Dec 1st, 2009, 2:37pm
 
Hi,

First day with processing...

Running this:

Code:
String mindate = "01/01/1900";
String maxdate = "01/01/2000";
String plotdate = "01/01/1975";

DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

Date DTmindate = df.parse("20/12/2005");  

And getting this:

Unhandled exception type ParseException.

If I put the code in a try/catch it runs fine, but I cannot put a setup()/draw() in after that.  I can put it in the draw(), but don't want to do that.

What am I doing wrong here?

Thanks!
Sam
Re: SimpleDateFormat Problem
Reply #1 - Dec 1st, 2009, 3:27pm
 
This seems to work:

Code:
String mindate = "01/01/1900";
String maxdate = "01/01/2000";
String plotdate = "01/01/1975";

DateFormat df;
Date DTmindate;

void setup() {
 size(100,100);
df = new SimpleDateFormat("dd/MM/yyyy");
try {
  DTmindate = df.parse("20/12/2005");
}
catch(ParseException e) {
  println(e);
}

println(DTmindate);
}

void draw() {
 
}


Note that setup() needs to run first in order for certain things to happen behind the scenes in Processing...  I always forget the intricacies but hopefully PhilHo will be along soon and clarify Wink
Page Index Toggle Pages: 1