How to get the system date and time using java
hi,
I want system date in my out put. how to access system date. can v use utill packaegs (or) sql. which one is the best to get.
Thanks & Regards,
Kenny.
hi,
I want system date in my out put. how to access system date. can v use utill packaegs (or) sql. which one is the best to get.
Thanks & Regards,
Kenny.
Here's an example to retrieve time:
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class testTime {
public void setTimeStamp() {
int hour, minute, second, time = 0;
Calendar cal = new GregorianCalendar();
hour = cal.get(Calendar.HOUR_OF_DAY);
minute = cal.get(Calendar.MINUTE);
second = + cal.get(Calendar.SECOND);
System.out.println (hour + ":" + minute + ":" + second);
}
public static void main (String args[]){
testTime app = new testTime();
app.setTimeStamp();
}
}