How can i get system time and day

How can i get the system current time and save it into a variable, then get the current day like wednesday and save it into another variable. Can someone teach me how to set this. thanks
regards,
albert

How can i get the system current time and save it
into a variable, then get the current day like
wednesday and save it into another variable. Can
someone teach me how to set this. thanks
regards,
alberti've managed to do this but in gui format hope it suites you.
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class time{
     private Container content;
          private JTextField timeField, dateField;
     public static void main (String[]args){
          time t = new time();
          t.TextClockWindow();
          t.showGUI();
     public void TextClockWindow() {
// Build the GUI - only one panel
JFrame frame = new JFrame();
content = frame.getContentPane();
timeField = new JTextField(6);
timeField.setFont(new Font("sansserif", Font.PLAIN, 20));
dateField = new JTextField(6);
dateField.setFont(new Font("sansserif", Font.PLAIN, 20));
content.setLayout(new FlowLayout());
content.add(timeField);
content.add(dateField);
// Create a 1-second timer and action listener for it.
// Specify package because there are two Timer classes
javax.swing.Timer t = new javax.swing.Timer(1000,new ActionListener() {
public void actionPerformed(ActionEvent e) {
Calendar now = Calendar.getInstance();
int h = now.get(Calendar.HOUR_OF_DAY);
int m = now.get(Calendar.MINUTE);
int s = now.get(Calendar.SECOND);
//String ampm =now.get(Calendar.AM_PM);
int y =now.get(Calendar.YEAR);
int mon=now.get(Calendar.MONTH);
int d=now.get(Calendar.DAY_OF_WEEK);
dateField.setText(""+y+ ". "+mon+ "."+d);
timeField.setText("" + h + ":" + m + ":" + s);
//to dispaly the current date so easily;stvworks
String rightNow = "" + new Date();
t.start(); // Start the timer
}//end constructor
public void showGUI(){
     JFrame frame = new JFrame("Time Frame.");
          frame.add(content);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
frame.setResizable(false);
frame.setVisible(true);

Similar Messages

  • How can i get the time and result together show in one Array or in Cluster?

    hello everyone i am a new user .I want to get the time and voltge form a Generater. How can i get the time and result together show in one Array or in Cluster?When i selecte the first(or third...) result then in the front panel display the time and the voltge.Thank you!
    I post the time and voltge NOT together photo
    Attachments:
    12345.GIF ‏54 KB

    You can create an array of clusters with one element being the time and the other being the voltage, like so (using the "Get Waveform Components" function):
    Message Edited by smercurio_fc on 10-17-2007 03:15 PM
    Attachments:
    pic.PNG ‏11 KB

  • How can we get current time date with resultset?

    Dear All,
    I have to insert current time date in the table.So,i need to get the current time and date with result set.So,I will first get the time date and then insert it into the table.
    I know how can we get current time and date without resultset.i have created this function its working.But now i want to use this.mean using resultset i want to put in the table.
    How can i do this?
    public static String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
    public static String now() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    return sdf.format(cal.getTime());
    }

    yuck. Why not simply set a "new java.sql.Date()" to the SQL parameter in question?

  • How can I  get System dates  with time scheduler using threads

    how can I get System dates with time scheduler using threads.is there any idea to update Date in my application along with system Date automatic updation...

    What the heck are you talking about and whatr has it to do with threads?
    Current time: System.currentTimeMillis. Date instances are not supposed to be updated.

  • I am in Saudi and trying to download navigon middle east. Every time I try to buy the app it will show up, says waiting and disappears. How can I get around it and not get lost on these crazy roads?

    I am in Saudi and trying to download navigon middle east. Every time I try to buy the app it will show up, says waiting and disappears. How can I get around it and not get lost on these crazy roads?

    I recently purchased a second hand new macbook air, although it was second hand to me the previous owner had never actually turned it on.
    Something doesn't make sense here, though I'm not saying the previous owner is lying....
    Time to send your serial # to iTS and let them see what's happening here.
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • How can I get the date and time and display it on the report main page?

    Gurus,
    How can I get the date and time and display it on the report main page?
    Thanks!

    Hello,
    You can create a Formula Colum returning a date :
    function CF_1Formula return Date is
    begin
    RETURN(SYSDATE);
    end;
    Put a Field in the Layout having this formula column as source .
    Regards

  • In version 3.x.x I used to be able to type search terms into the address bar and the page would load, similar to Google's "Feeling Lucky" button. Now it just brings up a Google search for the terms I typed in. How can I get this time saving feature back?

    In version 3.x.x I used to be able to type search terms into the address bar and the page would load, similar to Google's "Feeling Lucky" button. Now it just brings up a Google search for the terms I typed in. How can I get this time saving feature back?

    The change between Firefox 3.6.* and Firefox 4 is how location bar search works. In Firefox 3.6 it uses Google "Browse by name" search. With the browse by name search, it performs a Google search and if there is a clear match it will take you to the site, otherwise it shows the Google search result. With Firefox 4 it just performs a Google search if you type something which is not recognised as a URL.
    To get the Firefox 3.6 behaviour on Firefox 4 you need to change a hidden preference.
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # Locate the preference '''keyword.URL''', double-click on it and change its value to the link shown below
    [http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q= http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=]
    If you prefer, you can also do this by installing the Browse by Name extension - https://addons.mozilla.org/firefox/addon/browse-by-name

  • How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?

    How can I get the "Open" and "Save As" dialog boxes to open at larger than their default size?  I would like them to open at the size they were previously resized like they used to in previous operating systems.  They currently open at a very small size and the first colum is only a few letters wide necessitating a resize practically every time one wants to use it.  Any help would be appreciated.

    hi Prasanth,
    select werks matnr from ZVSCHDRUN into table it_plant.
    sort it_plant by matnr werks.
    select
            vbeln
            posnr
            matnr
            werks
            erdat
            kbmeng
            vrkme
            from vbap
            into table it_vbap
            for all entries in it_plant
            where matnr = it_plant-matnr and
                  werks = it_plant-werks.
    and again i have to write one more select query for vbup.
    am i right?

  • How can i get current time of a given timezone

    how can i get current time of a given timezone
    for example: Asia/Hong_Kong
    my code is like this, but the result is not correct.
    what's wrong?
    import java.util.*;
    public class test {
    public static void main(String[] args){
              String s = "Asia/Hong_Kong";
              String tempS = "";
              TimeZone myTime = new SimpleTimeZone(s);
              //TimeZone myTime = TimeZone.getTimeZone(s);
              Calendar myCal = new GregorianCalendar(myTime);
              tempS = myCal.get(Calendar.YEAR)+"-"+
                        (myCal.get(Calendar.MONTH)+"-"+
                        myCal.get(Calendar.DATE)+" "+
                        (myCal.get(Calendar.HOUR)+":"+
                        myCal.get(Calendar.MINUTE)+":"+
                        myCal.get(Calendar.SECOND);
              System.out.println(tempS);
    output is : 2001-7-15 11:16:48
    but the correct time should be: 2001-8-16 7:17:48
    the correct time should be 2001-8-16

    Certain indexes in the Calendar API start at 0 rather then 1, so, when you get the value, you may want to increment.
    I'm not sure why the time is incorrect. You may want to call getAvailableIDs() and make sure that the desired TimeZone ID is supported by your version. I doubt that Sun would have incorrect support for the time zone, but it may not be included, or perhaps it is included with a diffrent ID. You can always create your own time zone as well, by passing the String offset to getTimeZone(), the offset being how many hours beyond or before GMT. Hopefully this helps.

  • How can I get Flash Player and install it?

    I29/Aug/2010 17:37
    TO: Adobe Forum
    I am running Windows XP Home, and using Mozilla Firefox 3.6.8 as my browser.
    When I go to download and install the latest version of Flash Player, the ONLY option I get is to quit. In other words, I cannot download and install Flash Player. This even occurs at Adobe's own website.
    How can I get Flash Player and install it?
    Thank you in advance.
    Sincerely,
    Barry Karas

    First, you can manually download the installer here: http://get.adobe.com/flashplayer/otherversions/
    Second. On both my Mac (OS 10.6.4) and My PC (Vista Home Premium) I have had nothing but trouble with Firefox 3.6.8 and Flash player, Flash apps and Flash sites that require access to web cam or microphone or both.
    The last time Flash Player worked well with Firefox was 3.6.4, but I uninstalled 3.6.8 and went all the way back to 3.0 on both systems.
    Just a heads up. If you download the manual installer, and it still doesn't work, it ISN'T the Flash Player. It's Firefox. IE, Opera and Safari all work with it.
    Go to oldversion.com and get an older build of Firefox, uninstall 3.6.8, install the older one, go to Tools, and Options and turn off automatic checking for updates, so it doesn't try to take you back the the 3.6.8 "busted @$$ joint" that doesn't work worth poo.
    Maybe when they release 3.7, Firefox will have their act together with Adobe and Flash Player.

  • How can I get my Time Capsule to show up in finder?

    How can I get my Time Capsule to show up in finder?

    An alternate, and simpler method for most users is to open any Finder window, then look for the Time Capsule icon under the Shared heading on the left side of the window.
    When you click on the Time Capsule icon, a folder......named "Data", unless you have changed the name of the drive.....will appear to the right.
    Double-click "Data" to mount the Time Capsule drive on the desktop, where you can now drag/drop or copy/paste data to the drive.
    If the Time Capsule does not appear under the Shared heading when you open a Finder window......then you are likely using the Yosemite operating system on your Mac, and it will take some work to find it.
    In that case, Niel's method might be the better way to go.

  • How can i get system variable using java

    Hi,
    I just want to know how can i get system variables using java code.
    for example i want to get the the date for today or i want to get the number of processes that's running.
    Thanks alot

    Hi,
    I just want to know how can i get system variables
    using java code.
    for example i want to get the the date for today or i
    want to get the number of processes that's running.
    Thanks alotSome generic "system variables" are available though Java, usually through the System class.
    Date today = new Date();
    is instantiated with the current date and time.
    Other system values, like environment values, should be passed to java through the command line (-D option) by setting system properties.
    Finally, platform specific values like the number of processes running will have to be written in platform specific code and executed by JNI (java native interface).
    Java is platform or system agnostic. Common system values, like time, are implemented. Hopefully you won't need platform specific values.

  • I have a macbook pro and I connected a new iphone to my computer. Somehow all my pictures in the iphoto app deleted. How can I get them back, and no I do not have my TimeMachine On. Please help!

    I have a macbook pro and I connected a new iphone to my computer. Somehow all my pictures in the iphoto app deleted. How can I get them back, and no I do not have my TimeMachine On. Please help!

    If you are running Lion then all drivers are distributed through Software Update. You do not need to install anything, other than to install the printer in System Preferences > Print & Scan. If you already added the printer while it was connected using USB, you might want to delete it and set it up again wirelessly to avoid confusion. Or, give them two distinct names e.g. "Photosmart D110 (USB)" and "Photosmart D110 (wireless)".
    All scanning functions are now performed using Preview, but you can also access the scanner through the same Print & Scan preference pane, or with Image Capture.
    This HP document may help explain how driver software is distributed now:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03079365&cc=us&dlc=en&lc=en &product=4144493&tmp_track_link=ot_search#N108

  • I used to have eight genius mixes and now I have four...I changed the genres around and nothing happened...I've added many more songs since it changed from 8 to 4 mixes...how can I get more again and why did it go from 8 to 4?

    I used to have eight genius mixes and now I have four...I changed the genres around and nothing happened...I've added many more songs since it changed from 8 to 4 mixes...how can I get more again and why did it go from 8 to 4? I had the Hardcore mix and a rap mix and classic rock and grunge mixes...now I don't...I kinda want those back...the mixes I have now make no sense as most the songs on each do not correlate AT ALL to the genre mix they have been placed in. If someone could give me an answer that'd be great.

    1. Don't confuse "Apple ID" with iTunes Account ID.  You can have many Apple IDs but only one iTunes account active at a time.
    2. If you "changed" your iTunes account ID, you actually have 2 accounts - one under the old name plus the new name.
    3. You can't merge the accounts - they remain separate.  Apps purcahsed under the old account name will update ONLY WHEN THE PHONE IS SIGNED IN TO THE OLD ACCOUNT NAME  and visa versa.
    4. Likewise, you can sync only the apps, music, media purchased under the account the phone AND iTunes are signed in to.

  • How can i get current time in different TimeZone

    Hi alls,
    How can i get current time in different TimeZone.
    I've tried
    final Calendar calendar = Calendar.getInstance(GMT0_TIME_ZONE);
    final Date date = calendar.getTime();
    but it returns current time in my time zone not in GMT0

    a simple way would be:Sometimes gets you the right result (not during daylight saving), but always the wrong way.
    I would strongly recommend getting into the habit of handling Dates correctly. A Date is a universal instant in time - the number of milliseconds since midnight GMT on 1 January 1970. That instant corresponds to various dates and times, depending on your time zone and the effect of daylight saving. You make that conversion of a universal instant to a localized date/time using Calendar and DateFormat.

Maybe you are looking for

  • Can someone please help me with a sub query question?

    I need to list a 3rd party contract and then a list of students who belong to that contract. On the students segment of the listing I need to show students with student id, name, total credit hours, total amount spent on tuition, total amount spent o

  • Random successive crashes in AE CS6

    Hello Adobe Community! After effects CS6 crashes randomly about every 3 minutes or so. It just quits without any warning cough, or lag time. I only get this pop-up window when it's already too late. The crash doesn't seem to be triggered by any speci

  • Dynamic Software search

    Hi there, I am looking for a good software to make it easy to build/manage dynamic web sites. I use dreamweaver to build my sites.. I am looking for a software that makes things easy. The one lead I am looking to bid needs to be able to have their cl

  • Excel to SAP Macro Example

    Ok so here's an example of how to mass generate PDF's from PO placed on various Vendors. The entire code, if used on a VBA for Excel, does the task. Can the VBA coding in SAP be edited so that instead of generating PDF's, it can be used to change Del

  • Dreamweaver (CS4) interface got corrupted :-(

    Hi All, I was happily using DW CS4 on MS Vista for a while alread and suddenly after installation of Nero (CD burning software) I've found it corrupted ! As you may see on the above screenshot - interface elements are displayed "cut" or incomplete. I