date and time

i am new to java technology ,,,i am just trying to output the date and time of my pc example Mar 06 2004at 21:30
[133 byte] By [hjounia] at [2007-9-30 2:25:35]
# 1

use .....

import java.util.Calendar

import java.util.Date;

import java.text.SimpleDateFormat;

and do something like .....

Calendar myCal;

public Date getDate(){

myCal = Calendar.getInstance();

Date d = myCal.getTime();

return d;

}

System.out.println("Current time- "+(new SimpleDateFormat("MMM dd hh:mma")).format(d));

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html

and to get the format just right look here...

http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html

mohadib_a at 2007-7-16 13:35:24 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2

If you don't care about the precise format you can do it in very little code:

public class ShowDate {

public static void main(String[] argv) {

System.out.println(new java.util.Date());

}

}

paulcwa at 2007-7-16 13:35:24 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 3
this works out good for me ....System.out.println(new java.util.Date());thank you
hjounia at 2007-7-16 13:35:24 > top of Java-index,Archived Forums,New To Java Technology Archive...