Hi buddies,
I m facing some difficulties while setting system date and time?..Can anyone help to set System date & time?
Thanks
- Open a command prompt
- Type in: date
- it prompts you for new date/time
- enter new values.
- Open a command prompt
- Type in: date
- it prompts you for new date/time
- enter new values.
Thanks for reply.I want to set date & time programatically thru Java.
You can GET the date and time by using
System.currentTimeMillis();
This returns a long type that represents the number of milliseconds since Jan 1, 1970. You can format that long by using the java.util.Calendar and java.text.DateFormat classes.
You can GET the date and time by using
System.currentTimeMillis();
This returns a long type that represents the number of milliseconds since Jan 1, 1970. You can format that long by using the java.util.Calendar and java.text.DateFormat classes.
I m using Calendar class only as follows,
Calendar date = Calendar.getInstance();
date.set(i_year,i_mon,i_dt,i_hr,i_min,i_sec);
System.out.println("...."+date.get(Calendar.HOUR_OF_DAY)+"..."+date.get(Calendar.MINUTE)+"..."+date.get(Calendar.SECOND));
After setting the date,time ,I can fetch the updated date for this same instance thru programatically but still i can see the old time in system calendar.
For anyother instance as below ,i can get only the old date and not the updated one.
Calendar dateNew = Calendar.getInstance();
Please help.
The only way that you would be able to set the system time is through JNI calls to the OS.
The only way that you would be able to set the system time is through JNI calls to the OS.
Thanks.
I dont know how to use JNI , if u hav samples ,pls guide me with that.
Thanks.
I dont know how to use JNI , if u hav samples ,pls guide me with that.
I got a way to fix this,
String timestr="15:00";
String datestr="03-15-2008";
Runtime rt = Runtime.getRuntime();
Process proc;
proc = rt.exec("cmd /C date " + datestr);
proc = rt.exec("cmd /C time " + timestr);
However,this can only work on windows.
Thanks a lot for all ur support.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.