From: Kevin J. B. <kev...@bi...> - 2002-07-22 15:17:24
|
> From: =?iso-8859-1?q?Stephen=20Riek?= <ste...@ya...> > I was playing with Jython and noticed the most bizarre behaviour > > >>>>from java.text import SimpleDateFormat >>>>sdf = SimpleDateFormat("yyyy-MM-dd hh:mm:ss") >>>>date = sdf.parse("0000-00-00 00:00:00") >>>>date >>> > Sun Nov 30 00:00:00 CST 0002 > > > Why was the date 0000-00-00 converted to 2002-11-30 ? Because: 0000 = unspecified year = current year = 2002 01-01 = January 01 00-01 = December 01 00-00 = November 30 > Is this a flaw with the JDK java.util.Date package or jython artefact ? Depends on your definition of flaw. :-) The micro behaviors displayed here are useful, though counterintuitive in this case. The answer of whether something is a Jython artifact is always, "What does native Java code do?" import java.text.*; public class ZeroDate { public static void main( String[] args ) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd" ); System.out.println( sdf.parse( args[0] )); } } $ java ZeroDate 0000-00-00 Sun Nov 30 00:00:00 MST 0002 kb |