From: brian z. <bz...@zi...> - 2002-02-20 22:15:39
|
Mike, You are calling the method .parse on the Class DateFormat, not an instance of DateFormat. You should probably use an instance of SimpleDateFormat or call one of the many .get[Date|Time]Instance methods on DateFormat to get an instance. The missing argument in your calls to .parse is 'self'. >>> from java.text import DateFormat >>> date = '2/20/02' >>> j = DateFormat.getDateInstance(DateFormat.SHORT) >>> print j.parse(date) Wed Feb 20 00:00:00 CST 2002 >>> brian > -----Original Message----- > From: jyt...@li... > [mailto:jyt...@li...] On Behalf > Of Mike Hostetler > Sent: Wednesday, February 20, 2002 3:22 PM > To: jyt...@li... > Subject: [Jython-users] using java.text.DateFormat > > > > Maybe I'm doing something dumb here -- I dunno. I'll > honestly admit that > I know more about Python than Java . . > > I'm wanting to emulate something like the time.strpformat in the > CPython/Unix library. The closest I've found is the > java.text.DateFormat class > in the Java standard library. I think I'm using it right, but I get a > very strange error: > > >>> from java.text import DateFormat > >>> date > 'Wednesday February 20 12:06:17 CST 2002' > >>> t = DateFormat.parse(date) > Traceback (innermost last): > File "<console>", line 1, in ? > TypeError: parse(): expected 2-3 args; got 1 > > According to the Java API docs, DateFormat.parse only > requires 1-2 args: > > parse > public Date parse(String text) > throws ParseException > > parse > public abstract Date parse(String text, ParsePosition pos) > > Anyone have any suggestions?? > > -- mikeh > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |