kgsoft_sys
asked on
Generating Current time...
Dear expert...
can any of you provide me with the code how to generate current time in java...i need it urgently..thank !
from : Alex Gan
can any of you provide me with the code how to generate current time in java...i need it urgently..thank !
from : Alex Gan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
System.currentTimeMillis() produces the current time in milliseconds with a resolution dependent upon your the native system's clock.
java.util.Date wraps the millisecond value and provides some comparison behavior although most of its useful behavior has been deprecated and moved to java.util.Calendar and its concrete subclasses. The no-arg constructor of Date initializes the new Date object with the current time provided by System.currentTimeMillis() .
java.util.Calendar provides facilities for getting and setting specific date parts (like seconds, months, years) and for performing date arithmetic.
java.text.DateFormat and its more useful class java.text.SimpleDateFormat perform Date formatting to Strings and parsing from Strings.
Taken together, one or more of these classes is likely to have the functionality you are looking for with respect to "generating the current time".
Best regards,
Jim Cakalic
java.util.Date wraps the millisecond value and provides some comparison behavior although most of its useful behavior has been deprecated and moved to java.util.Calendar and its concrete subclasses. The no-arg constructor of Date initializes the new Date object with the current time provided by System.currentTimeMillis()
java.util.Calendar provides facilities for getting and setting specific date parts (like seconds, months, years) and for performing date arithmetic.
java.text.DateFormat and its more useful class java.text.SimpleDateFormat
Taken together, one or more of these classes is likely to have the functionality you are looking for with respect to "generating the current time".
Best regards,
Jim Cakalic
DateFormat dateFormat = DateFormat.getDateInstance ();
Calendar calender = dateFormat.getCalendar();
System.out.println("time"+ calender.g etTime());
Calendar calender = dateFormat.getCalendar();
System.out.println("time"+
public static void main(String[] args) {
System.out.println("Curent
}
}
Compile this and run'it.