[team33] GregorianCalendar and Date

  • From: Alexei Kounine <aleko379@xxxxxxxxxxxxxx>
  • To: team33@xxxxxxxxxxxxx
  • Date: Fri, 19 Nov 2004 19:02:32 +0100

When you get a Date from the Database (results.getDate("date")) from the
database, you just keep it this way, and put it in the Link object as a
Date (please change it back to Date).

It's the same for putting a date into the table. It works very well with
Date.

Just if for some reasons you need to print a date in a nice format. And
this is especially true for the Testing team, here is an example of how
you can do this:

Date date = new Date(); //gives you the exact current date and time
milliseconds
    
Format formatter = new SimpleDateFormat("MM/dd/yy"); //an object used in
//conversion
String dateStr = formatter.format(date); //you format your time given in
//milliseconds to the format MM/dd/yy

Is it clear?

This is useful for testing because when doing Date date = new Date() it
gives you the precise time at the creation time.
For a timer, just create 2 dates, and substract them to get the
execution time.

or you can use:
System.currentTimeMillis();

Have a look at the API
http://java.sun.com/j2se/1.4.2/docs/api/

Please do some good and intelligent coding, as i asked this afternoon.
Don't hesitate to ask questions, and good luck

Alex
-- 
--------
Alexei Kounine
Email: 
        <alexei.kounine@xxxxxxx>
        <aleko379@xxxxxxxxxxxxxx>
Site:
        http://anciensdeferney.free.fr/intouch


Other related posts:

  • » [team33] GregorianCalendar and Date