Set time in Java

How can I set the system time in Java?

hi, you can use the Runtime.getRuntime().exec(...);
Method to use the dos command "time"

Similar Messages

  • Program to Set System Time in Java

    Is there any way to set the system time through Java. If there is can you help me some information.
    Regards,
    Shivakumar Thota

    Hey Hey,
    You could run Runtime.exec() to execute a command such as VBScipt to do it.
    Other than that you may have to take a look at Java Native Interface(JNI) that will basically take control of doing anything you need.
    Also, You may want to post this in "New To Java" or some other forum other than Java Web Start. You'll get more people to help ya.
    Hope this helped,
    --Ryan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Setting Up a Java Web Server on Linux

    Greetings,
    After a lot of reading, I've decided to learn Java server-side technologies (I already know Java (desktop)
    but with little experience) in order to develop my database driven dynamic website projects.
    However, I'm completed lost between the hundreds of acronyms related to Java and the "thousands" of technologies involved.
    Google hadn't help me understand what they really are and how they relate with each other.
    Even though is easy to find what they stand for and some faqs/descriptions, it hasn't been enought to clear my mind.
    I want my webserver application to do, among other things, the following:
    Retrieve Data from a database, do generate dynamic html files.
    Story Data on the database, from html forms.
    Send automaticly emails for multiple users. (newsletter for example)
    E-Commerce.
    Html graber/parser (I don't know if this is the right word, I mean a program that for example, goes to a URL with an html
    table, and stores that information in a database table, as long as the format didn't change).
    Real Time Chat feature.
    Database connection pooling, caching, and other important optimizations.
    I'm not asking for how to develop or configure this features nor what components and programs, must be installed.
    At the moment, I only want to know how to set up a Java solution that will support them when they are needed.
    *** Linux ***
    I want to set up my webserver on a linux distribution.
    In that respect, I don't know if I should choose RedHat or Fedora Core.
    I've heard that fedora is better for a webserver (having in mind that Red Hat Enterprise AS/ES aren't free).
    But I've read in several sun turorials/webpages references to RedHat (on a J2EE context).
    So I'm wondering if is better to go for Fedora or RedHat. Are there pros & cons? They equally support Java?
    *** Technologies ***
    Then in starts the acronyms problem.
    What do I need to install, in what order, for what?
    Some aconyms and technologies, I have read about but don't fully understand are the following:
    Apache
    J2EE
    J2EE 1.4 SDK
    SUN Java System Application Server Platform Edition 8
    J2SE 1.4.2 SDK
    SUN Java Enterprise System
    Tomcat
    Struts
    Cocoon
    JBoss
    I already know J2EE is only a specification. What implements that specification? Sun Java System Application Server?
    J2SE SDK? or Tomcat?
    What is the role of each technology, namely Apache, Tomcat, Sun Application Server?
    What is the Sun Java Enterprise System?
    How do Struts, Cocoon, JBoss relate to Java?
    Which of these technologies are mutually exclusive (analogous)?
    *** Doubts ***
    Then, I have some doubts that are keeping me from starting to study seriously the important techonologies, because I don't
    want to lose lot's of time and effort learning them to after a dillusion start everything again with PHP (the language
    which make me think and read a lot before going for Java). To keep this from happening, I would like to know the following:
    I want to use Java for developing websites with commercial/profitable use for my company, in some throught e-commerce,
    and in other by banners. I want to do everything by the book, with required licenses.
    ------ Java is Free?
    Is Java Completely Free or it might be possible that at a certain point, when I need some component or library,
    multi-machine webserver, performance or security for high-traffic I will see "buy now" instead of "download now"?
    For what they may "ask for money"? and what are the disavantages if I can't buy?
    For example, "Java System Application Server Standard Edition 8.1 2005Q1" and
    "Java System Application Server Enterprise Edition 8.1 2005Q1" cost $2.000 and $10.000 respectively. That is money.
    (http://www.sun.com/software/products/appsrvr/index.xml). What are the disavantages if stick to the free edition?
    Features like (from sun site)
    Standard Edition:
    Extends the capabilities of the Platform Edition to provide secure, remote, multi-instance, multi-machine management.
    It is aimed at high-volume applications and Web services.
    Enterprise Edition:
    Further extends the capabilities of the Standard Edition to provide continuous availablity for applications and
    Web services. It is aimed at business critical, high value applications and Web services.
    Suppose I achive lots of traffic and I keep the free platform edition.
    I won't be able to have a multi-machine webserver set up correctly?
    What are the drawbacks? How big are the performance penalties?
    ------ Technologies Availability
    Finnaly, I have the idea (I don't know if it's accurate) that there are Sun versions and Open-Source Free versions
    of doing or supporting the same Java related thing.
    Despite the way I choose to set up a Java webserver, I will always have all J2EE techonolies like:
    Java API for XML-Based RPC (JAX-RPC), JavaServer Pages, Java Servlets, Enterprise JavaBeans components,
    J2EE Connector Architecture, J2EE Management Model, J2EE Deployment API, Java Management Extensions (JMX),
    J2EE Authorization Contract for Containers, Java API for XML Registries (JAXR), Java Message Service (JMS),
    Java Naming and Directory Interface (JNDI), Java Transaction API (JTA), CORBA, and JDBC data access API.
    I really appreciate some help. I could learn the basics of all this "stuff" before asking. But the point why I'm asking
    is precisely not starting to learn something I may won't use. Obviously, I will have to make a lot of reading during maybe
    months before writing the first line of code of my projects, but being certain that it will fit my needs.
    I will be very thankful if you can enlightme in my fedora/redhat, setup, free/cost and technologies avaibility issues.
    Thanks Beforehand,
    Pedro Vaz

    Apache is a free Web-server.
    Tomcat is a servlet (and JSP) container. It can be stand-alone or can be used together with a Web server (like Apache).
    J2EE's scope is much wider than the servlet stuff, but a standalone Tomcat is a good starting point to servlets and JSP.
    One of our "real-world" applications is run by a standalone Tomcat using POI and Velocity. I did not regret this architectural decision.

  • How to set up a Java Plug-in Download page in case of netscape?

    hai all of you,
    i have a problem regarding downloading plugin.
    i am using <object > and <embed> tags to download the plugins inorder to run the applets. but it is taking long time to download the plugin form sun.com.
    so what i have done is, i downloaded the plugin.exe file and .cab file and put it in my tomcat server mainted by other party.(y application if for internet purpose only.)
    i refered to http://java.sun.com/products/plugin/1.2/docs/intranet.html. there it is mentioned that, to download the plugin.
    for I.E i can able to change the code.
    but for NetScape it's a little bit confusing.
    i have downloaded the binary file in my own directory.
    here he is asking to set up a java plugin-in download page.
    instead of this "plugin-install.html" page what page i should create and what should be the code in this page if i have to write on my own. please let me know if anybody know about it.
    following para is from sun.com
    "To deploy Java Plug-in in intranet environments with Navigator, you need to download and store the Java Plug-in binary file on one of your web servers. Then you need to set up a Java Plug-in Download page and modify the pluginspage attribute in the EMBED tag to refer to this page. The Download page should have options to download different versions of Java Plug-in, such as for Windows and Solaris. For example, if you have set up the Java Plug-in Download page at "http://javaweb.eng/plugin/" and the page is called plugin-install.html, you can specify the pluginspage as "http://javaweb.eng/plugin/plugin-install.html". "
    thanks
    by
    sambareddy

    I have successfuly done this.
    Change the converted html as per the instructions to point to another page.
    Here is an example of the new html page you need to create:
    <html>
    <head>
    <title>Java Plugin Install Page</title>
    </head>
    <body>
    <h2><center>Java Plugin Install Page</center></h2>
    <p></p>
    <h3>Windows Version Only!!!</h3>
    Click here to Download Plugin
    <p></p>
    <p>You may or may not be asked to either save or run from current location</p>
    <p>If the run from current location is available, use that option</p>
    <p>If you can only save the file, then save it to your workstation and exit the download page and exit Netscape. Then using Windows Explorer, go to where you downloaded the file and double click on the file to run it. Accept all options during the install process and once it has finished try accessing your web page again using Netscape. You should then get to the web page or application and this page will not apppear again.
    </body>
    </html>
    If you put the file j2re-1_3_1-win.exe on a web server somewhere then you will have to prefix the file with
    http://yourwebserverdirectory/
    Hope this helps.

  • Getting the current time using java.sql.Time

    I need to set the current time in a database field. I tried the following code (using my logic) to set the current time. But, I end up getting "Jan 1, 1970" in the time field in the database.
    Here is the code :
    Calendar cal = Calendar.getInstance();
    Java.sql.Time now = java.sql.Time.valueOf(
              cal.get(Calendar.HOUR_OF_DAY) + ":" +
              cal.get(Calendar.MINUTE) + ":" +
              cal.get(Calendar.SECOND));
    What should I do to get the current time in the "now" variable? Right now, it ends up in the database as "Jan 1, 1970".
    Thanx in advance.

    Can you show me the code to do SimpleDateFormat?
    Assuming that I use the following skeleton to get the
    time value from the database, can you show me the
    code for the missing link (so as to display in the
    format "hh:mm:ss") ?
    java.sql.Time timeFromDb =
    obj.getActionTime();
    // The above code gets the "time" field from
    the database into "timeFromDb"
    // Use SimpleDateFormat to display the time
    java.text.SimpleDateFormat sdf = new
    java.text.SimpleDateFormat("hh:mm:ss");
    // Now what do I do with "sdf" and
    "timeFromDb" ?
    // Print out the time value
    System.out.printf("Time is : %s\n",
    .... );Hi,
    I don't know if you want 24h clock or not. This is the pattern for 24h clock.
    "HH:mm:ss"
    You get the text string by calling sdf.format(timeFromDb)
    Kaj

  • How can I calculate the total time in java?

    Hello!
    I need to calculate the total time!
    For example I have start time:
              Format formatter1;
              Date date1 = new Date();
              formatter1 = new SimpleDateFormat("hh:mm:ss");
              String startTime = formatter1.format(date1);
              //startTime = "14:20:40";
    And I have finish time:
              Format formatter2;
              Date date2 = new Date();
              formatter2 = new SimpleDateFormat("hh:mm:ss");
              String finishTime = formatter2.format(date2);
              //finishTime = "08:30:55";
    So, after manually calculating, I get total time: "18:10:15"
    How can I calculate the total time in java? (Using formatter1 and formatter2 I suppose)
    What I need is to print "total 18:10:15"
    Thanks!

    800512 wrote:
    I did the following but, I think something is wrong here:
    I defined before: Date date1 = new Date(); Date date2 = new Date();
    And it should be exactly 5 seconds between them.
    I found delta between date1 and date2:
    Format formatter = new SimpleDateFormat("HH:mm:ss");
              long timeInMilliFromStart = date1.getTime() - date2.getTime() ;
              Date date3 = new Date(timeInMilliFromStart);
              String timeInSecFromStart = formatter.format(date3);
    and I get always
    //timeInSecFromStart = 02:00:05
    But it should be exactly 00:00:05.
    What can be a problem?Because, like I said, a Date measure an instant in time, not a duration. So when you have 5000 ms, and you turn that into a Date, that means 5 sec. after the epoch, which works out to 1/1/1970 00:00:05.000 GMT.
    As I mentioned, if you're not currently in GMT, then you have to set the TZ of the DateFormat to GMT. Right now, it's showing you the time in your TZ. If you included the date in your SimpleDateFormat, you'd see either 1/1/1970 or 12/31/1969, depending on which TZ you're in.
    Bottom line: You're trying to use these classes in a way they're not meant for, and while you can get the results you want for a limited set of inputs if you understand what these classes do and how to work with that, it's a brittle approach and comes with all kinds of caveats.

  • My Apple TV all of a sudden refuses to show my movies from my MacBook and says it needs to set time network. What is that?

    My Apple TV all of a sudden refuses to show the movies from my MacBook and says it needs to set time network. What is that?

    Welcome to the Apple Community.
    The Apple TV should set it's time automatically from the network time server, if it isn't doing this try restarting the Apple TV by removing ALL the cables for a 30 seconds, if this fails try resetting or restoring it.

  • HT201250 I have two external hard drives. One is my Time Machine backup drive.  The other I use for external storage of files (documents, photos, movies, etc).  Can I set Time Machine to backup BOTH my Mac hard drive and my other external hard drive?

    I have two external hard drives. One is my Time Machine backup drive.  The other I use for external storage of files (documents, photos, movies, etc).  Can I set Time Machine to backup BOTH my Mac hard drive and my other external hard drive?

    Yes you can make multiple backups on one hard drive, for example if you’ve 1TB hard drive installed in your PC and you’ve two Mac Machines with 500GB drive each then you just make two backup images with size of 500GB each.
    http://www.halfspot.com/use-your-pc-hard-drive-for-time-machine-backup/

  • How to change a setting in the Java Control Panel with command line

    Hi,
    I am trying to figure out how to change a setting in the Java Control Panel with command line or with a script. I want to enable "Use SSL 2.0 compatible ClientHello format"
    I can't seem to find any documentation on how to change settings in the Java Control Panel via the command line
    Edited by: 897133 on Nov 14, 2011 7:15 AM

    OK figured it out. This is for the next person seeking the same solution.
    When you click on the Java Control Panel (found in the Control panel) in any version of Windows, it first looks for a System Wide Java Configuration (found here: C:\Windows\Sun\Java\Deployment). At this point you must be wondering why you don't have this folder (C:\Windows\Sun\Java\Deployment) or why its empty. Well, for an enterprise environment, you have to create it and place something in it - it doesn't exist by default. So you'll need a script (I used Autoit) to create the directory structure and place the the two files into it. The two files are "deployment.properties" and "deployment.config".
    Example: When you click on the Java Control Panel it first checks to see if this directory exists (C:\Windows\Sun\Java\Deployment) and then checks if there is a "deployment.config". If there is one it opens it and reads it. If it doesn't exist, Java creates user settings found here C:\Users\USERNAME\AppData\LocalLow\Sun\Java\Deployment on Windows 7.
    __deployment.config__
    It should look like this inside:
    *#deployment.config*
    *#Mon Nov 14 13:06:38 AST 2011*
    *# The First line below specifies if this config is mandatory which is simple enough*
    *# The second line just tells Java where to the properties of your Java Configuration*
    *# NOTE: These java settings will be applied to each user file and will overwrite existing ones*
    deployment.system.config.mandatory=True
    deployment.system.config=file\:C\:/WINDOWS/Sun/Java/Deployment/deployment.properties
    If you look in C:\Users\USERNAME\AppData\LocalLow\Sun\Java\Deployment on Windows 7 for example you will find "deployment.properties". You can use this as your default example and add your settings to it.
    How?
    Easy. If you want to add *"Use SSL 2.0 compatible ClientHello format"*
    Add this line:
    deployment.security.SSLv2Hello=true
    Maybe you want to disable Java update (which is a big problem for enterprises)
    Add these lines:
    deployment.javaws.autodownload=NEVER
    deployment.javaws.autodownload.locked=
    Below is a basic AutoIt script you could use (It compiles the files into the executable. When you compile the script the two Java files must be in the directory you specify in the FileInstall line, which can be anything you choose. It will also create your directory structure):
    #NoTrayIcon
    #RequireAdmin
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    Func _JavaConfig()
         $ConfigFile_1 = @TempDir & "\deployment.properties"
         $ConfigFile_2 = @TempDir & "\deployment.config"
         FileInstall ("D:\My Documents\Autoit\Java config\deployment.properties", $ConfigFile_1)
    FileInstall ("D:\My Documents\Autoit\Java config\deployment.config", $ConfigFile_2)
         FileCopy($ConfigFile_1, @WindowsDir & "\Sun\Java\Deployment\", 9)
         FileCopy($ConfigFile_2, @WindowsDir & "\Sun\Java\Deployment\", 9)
         Sleep(10000)
         FileDelete(@TempDir & "\deployment.properties")
         FileDelete(@TempDir & "\deployment.config")
    EndFunc
    _JavaConfig()
    Now if you have SCUP and have setup Self Cert for your organization, you just need to create a SCUP update for JRE.
    Edited by: 897133 on Nov 16, 2011 4:53 AM

  • How to change system time through java program

    Hi
    I want to know, how to change system time through java program.
    give me a idia with example.
    Thanks

    There isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
    ~

  • HT201514 i can't see the time capsule from airport utilities. i did follow "From the Apple menu, choose System Preferences. Choose View Time Machine. Set Time Machine to On if it is off. .....but i couldn't find the time capsule from airport utility.....

    i did follow "From the Apple menu, choose System Preferences. Choose View > Time Machine. Set Time Machine to On if it is off "
    . .....but i couldn't find the time capsule from airport utility..... why?

    Are you using a new 802.11ac Time Capsule - the "tall" one - and are you still using Mac OS X 10.6.8?
    You need OS X 10.7.5 "Lion" or later, or an iOS device, to configure an 802.11ac Time Capsule:
    http://manuals.info.apple.com/MANUALS/1000/MA1645/en_US/airport_time_capsule_802 11ac_setup.pdf
    See page 12.

  • Can I hide the set time in the event boxes in Week View?

    Can I hide the set time in the event boxes in the Week View?

    David
    No way around this that I can find. That toolbar pops up if you pause the show.
    The nearest I could figure is to use the settings button for a long slide - 'Play each slide for 120 seconds' then tapping the arrows will move the slides along without showing the toolbar. And the 120 second slide is almost as good as a pause.
    iPhoto menu -> Provide iPhoto Feedback
    Regards
    TD

  • Where can I find a video that tells me how to set time on photos to 1 second each?

    where can I find a video that tells me how to set time on photos to 1 second each? Where can I find a video that tells me how to add black space to the sides of all photos so that they display completely instead of only showing the center (which shows peoples' crotches but cuts off their heads- great huh?)? Would like to import whole folders of photos, set each to 1 second, have each display completely without distorting to fill. and "play" the timeline as I build it so that I can see if its working before putting in 2000 pics?

    Hello Cain,
    You can see the Domestic Outbound Scenario (DOT) for how to use incompatibility scenario.
    You can find the Customizing guides at SAP Support Poratl.
    Regards
    Nitesh

  • Start recording video at a set time of day and off at a set time of day, and or can start rec video when motion detected, till no motion detected for a set period

    is there an app for iphone which can be set to start recording video at a set time of day and off at a set time of day, and or can start rec video when motion detected, till no motion detected for a set period. basically someone is vandalising my vehicle and i really really want to catch the mongrel
    thanks for any suggestions

    Nope.

  • How may I automatically stop and start Mail services at a set time please

    Hi folks. I was wondering if anyone could tell me how to automatically stop and start Mail services (or any other services) at a set time please in Leopard Server? Is there a script someone has created which might help?
    Cheers, David ( a realy newbie when it comes to administering OS X server)

    launchd works through a series of XML documents that define tasks to run, either at launch, on a time schedule, in response to network events, etc.
    So you'll need to create two .plists - one to start the mail server and one to stop it. They should be saved in /Library/LaunchDaemons. I'd suggest something like:
    /Library/LaunchDaemons/local.postfix.stop.plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple
    .com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>Label</key>
      <string>local.postfix.stop</string>
      <key>ProgramArguments</key>
      <array>
        <string>/usr/sbin/serveradmin</string>
        <string>stop</string>
        <string>mail</string>
      </array>
      <key>StartCalendarInterval</key>
      <dict>
        <key>Hour</key>
        <integer>1</integer>
        <key>Minute</key>
        <integer>00</integer>
      </dict>
    </dict>
    </plist>
    and /Library/LaunchDaemons/local.postfix.start.plist:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple
    .com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>Label</key>
      <string>local.postfix.start</string>
      <key>ProgramArguments</key>
      <array>
        <string>/usr/sbin/serveradmin</string>
        <string>start</string>
        <string>mail</string>
      </array>
      <key>StartCalendarInterval</key>
      <dict>
        <key>Hour</key>
        <integer>4</integer>
        <key>Minute</key>
        <integer>00</integer>
      </dict>
    </dict>
    </plist>
    You'll need to either use launchctl load /Library/LaunchDaemons/local.postfix.stop (or start) to load the tasks, or reboot your server.
    I'm curious, though, as to why you want to do this. Mail is typically one of the services that people want to run 24/7 so they don't miss out on any emails (even though SMTP can tolerate this). Why do you want to shut yours down?

Maybe you are looking for

  • I want to upgrade my hard-drive in  2010 model MacBook Pro 13

    I would like to increase the hard drive size on my 13" Macbook Pro from 250 GB to 500 or 750 GB. Amazon carries the WD5000BEVT and the WD7500BPVT drives. Reading various comments about them, I'm concerned about how quiet and efficient they are in a M

  • PC Webcams Compatible With iSight?

    My friend wants to get a PC webcam so she can videochat with me. However, I often find that many PC webcams do not work in iChat when I attempt to connect with them. Does anyone know of a PC webcam that can videochat with my iSight?

  • Duplicates in the target table.

    Hi, I am working on ODI 10. In one of my interface when ever I executes there are some duplicates are coming to the target table. Say if the count of the rows around 5000 in the source table and in the target it would be around 120000. Even after usi

  • Error loading an X-4 std joboption into Distiller

    I have a customer running CS4 / OS 10.5.8. We recently changed our CS4 presets to encompass the X-4 2008 Standard. When installing he gets this error: Error in /Library/Application Support/Adobe/Adobe PDF/Settings/PDFX4 2008.joboptions: /CheckComplia

  • Zen Xtra-Failure to uninstall and what to reinsta

    My Zen Xtra (USB on XP) worked perfectly until the sudden failure of CMS to load a new playlist. The Zen itself still works fine. So I thought a quick uninstall reinstall would be reasonable but a 23. MB "Creative" file in "Program Files" would not u