| | |
How to set System Date & time
Thread Solved |
You can GET the date and time by using
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.
java Syntax (Toggle Plain Text)
System.currentTimeMillis();
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. •
•
Join Date: Mar 2008
Posts: 41
Reputation:
Solved Threads: 0
•
•
•
•
You can GET the date and time by using
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.java Syntax (Toggle Plain Text)
System.currentTimeMillis();
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.
•
•
Join Date: Mar 2008
Posts: 41
Reputation:
Solved Threads: 0
•
•
•
•
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.
![]() |
Similar Threads
- Dual-Boot (Multiboot), 9x-2000, 9x-XP (Windows tips 'n' tweaks)
- trojans...now nothing opens and I get a paint can't open error (Viruses, Spyware and other Nasties)
- Windows installaton message "Setup didn't find any hard disk drives installed..." (Storage)
- Open In New Window Php (PHP)
- getters&setters (Java)
- mock credit card with mysql & filewriter INSERT into mysql (Java)
- mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Creating an event or an action to a button. (PHP)
- Can Someone please check my project & comment/tips (C)
Other Threads in the Java Forum
- Previous Thread: algorithm help
- Next Thread: dont know how to delete string..help!
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






