Valid TimeStamp difference between JDK 6 & JDK 7

Is the below statement valid in Java 7?

Timestamp.valueOf("0000-00-00 00:00:00.000000");

because building the above code with JDK 1.6 works just fine but while doing the same with JDK 1.7 I am getting:

Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]

Jon Skeet
people
quotationmark

Well it's syntactically valid Java code, but I wouldn't expect it to work at execution time:

  • 0 isn't a valid month
  • 0 isn't a valid day-of-month
  • 0 may or may not be a valid year, depending on how you're counting things. (It appears to work with JDK 7, but I wouldn't use it myself.)

I'd use "0001-01-01 00:00:00.000000" - which doesn't throw an exception. That's if you really, really need such a thing, of course - if this is a magic value to use in absence of "real" data, perhaps you need a nullable column instead?

people

See more on this question at Stackoverflow