swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Timestamp class inside.


From: Joshua Madden
Subject: Re: Timestamp class inside.
Date: Sat, 3 Mar 2001 13:28:02 -0800 (Pacific Standard Time)

On Sat, 3 Mar 2001, Paul E Johnson wrote:

> I want to put the day/time of creation into file names in order to keep
> records on runs. I put the same stamp on files that save parameters,
> data, etc, and after a few weeks it is the only way I've found to
> remember what I did.  I found myself rewriting the code that fetches the
> time and converts to a string over and over, making the same mistakes
> over and over.  Aha, create a class, use over and over! I settled in on
> this way, that avoids overrunning buffers (so far as I know), doesn't
> leak memory, and gives output I want.  Feel free to use it if you like,
> or improve and redistribute.
> 
> I wish something like this was in Swarm itself so I could call it from a
> Java program, so I won't have to learn how to do the timestamp in Java
> :).  If you have Java code that does this, please share.

Take a look at the Java Date, DateFormat, and SimpleDateFormat classes.  
Which of these you might want to use will depend on exactly what you want
the stamp to look like.  

If it would serve to put the date/timestamp into the file instead (rather
than in the filename) there's a slick mechanism that you can use:

ObjectOutputStream.writeObject(new Date());

which is then read back as follows: 

(Date)(ObjectInputStream.readObject());

and then you can parse the Date.

Joshua

address@hidden Per Obscurius...cs.uoregon.edu/~jmadden
    Joshua Madden: Information Scientist, Musician, Philosopher-At-Tall
It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]