I spent about an hour, trying to figure out how to use the simpleDateFormat java library in Processing… It seemed so straight forward, yet I couldn’t get it to work…
Well, it seems that the only thing I had to add is a try/catch.
So, this example works:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import java.text.*; Date myDate; void setup(){ SimpleDateFormat myDateFormat = new SimpleDateFormat("yyyyMMdd"); try { myDate = myDateFormat.parse("20001010"); } catch (Exception e) { println("Unable to parse date stamp"); } println(myDate); } |
but this one does not, even though there is no error to catch…
1 2 3 4 5 6 7 8 | import java.text.*; Date myDate; void setup(){ SimpleDateFormat myDateFormat = new SimpleDateFormat("yyyyMMdd"); myDate = myDateFormat.parse("20001010"); println(myDate); } |
I’m not sure why this is the case. If anyone does, please let me know!