i need a unique string that i can assign to filenames. so, i'm trying to use the Date() class for this. *** code fragment *** Date what=new Date(); String thisMoment=String.valueOf(what); ***************** this returns: Wed Mar 14 16:44:44 PST 2001 how do i get the milisecond portion of this. more generally, i guess this becomes a question of how to read the following javadoc. *** from Java Documentation *** Date public Date(long date) Allocates a Date object and initializes it to represent the specified number of milliseconds since January 1, 1970, 00:00:00 GMT. Parameters: date - the milliseconds since January 1, 1970, 00:00:00 GMT. **************** thanks in advance. jay
Use the getTime() method on your date object to return the number of milliseconds since January 1, 1970 (as a long). You could then convert the long toString().
Both of these are static methods, so you don't have to create a Date object. ( Unless you really want too... ) HTH, -Nate
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jay X Brown
Ranch Hand
Joined: Jan 26, 2001
Posts: 51
posted
0
thanks guys! but, while we're on the topic, how does one get all this from the javadocs of the type that i've quoted? any guide for reading javadocs? thanks jay
Hi Jay! You may be looking at old documentation. I checked out the documentation at the same link Cindy posted, and in addition to the documentation you posted above, there was a "See Also" section that pointed to System.currentTimeMillis(). Of course, it's just a ton of information to absorb, so I'm sure it just takes some time working with the classes.