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.

Similar Messages

  • 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 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 the time to appear on my stored data in notepad

    Hi all,
    I was wondering how can i get the time to appear on my stored data in notepad? I saw an example before but i forgotten which example was it.. Any ideas??
    holla
    Attachments:
    TextFile1.txt ‏3 KB

    Hi
    Im using Labview 8.2. Currently it just shows the data without the time. Im not sure what to do. It works perfectly though. I just want the time to appear on my notepad along with my data
    holla
    Attachments:
    Testing1.txt ‏1 KB
    Untitled 231_LV80.vi ‏23 KB

  • How can I get my time machine to allow me to recover files again? After upgrading to OS X, the time machine still backs up the files; but, I'm not able to navigate within the time machine or select any folders or files for restore.

    How can I get my time machine to allow me to recover files again?
    After upgrading MBA to OS X, the time machine still backs up the files; but, I'm not able to navigate within the time machine or select any folders or files for restore.
    I've searched and can not find a solution to the problem that's being encountered.

    Yeap that all makes sense now.
    Do you only have the current backup showing in the TM display?? Won't it fill in the rest?
    Over wireless are you waiting for the indexing to finish.. ??
    Previous backup may not show for a couple of hours.
    Long short of it.. Mavericks version of TM is a pain.
    Sometimes it is easier to completely ignore the TM backup and do the restore manually.
    I have posted the details here. See if this helps.
    Can't access old files on time capsule

  • How can I get a time stamp on text message without turning on "read"???

    How can I get a time stamp on text message iPhone 5 IOS 7? (Without having to send read receipt)

    You can make the "Visit Date" column visible in the Bookmarks Manager (Library) via "Views > Show Columns"
    * Bookmarks > Organize Bookmarks
    *http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox

  • 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 I get the time in Microsecond with JNI ?

    How can I get the time in Microsecond with JNI ?

    JNIEXPORT jdouble JNICALL Java_Win32Native_queryPerformanceFrequency (JNIEnv *env, jobject obj) {
         LARGE_INTEGER lFrequency;
         ::QueryPerformanceFrequency(&lFrequency);
         return (jdouble)lFrequency.QuadPart;
    JNIEXPORT jdouble JNICALL Java_Win32Native_queryPerformanceCounter (JNIEnv *env, jobject obj) {
         LARGE_INTEGER lpCounter;
         ::QueryPerformanceCounter(&lpCounter);
         return (jdouble)lpCounter.QuadPart;

  • 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.

  • 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 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);

  • How can I get a time stamp in the historyfile

    I can´t see date and time in the history file, how can I get that information on a MAC ?

    You can make the "Visit Date" column visible in the Bookmarks Manager (Library) via "Views > Show Columns"
    * Bookmarks > Organize Bookmarks
    *http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox

  • How can I get the time for a simulate signal express vi waveform?

    I tried converting to an array and then indexing, but every index I try only gives me the y value. See attached VI for clarification on what I mean.
    Attachments:
    simulate signal.vi ‏49 KB

    You will have to keep track of that yourself.  You are sampling at 360kHz.  This means that each sample is ~2.8us.  You can easily get the time by taking that dt (2.8us) multiplied by the sample index and adding the time at which the first sample was taken.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How can i get the time detail with messageDateField ?

    Is there any common way of getting the time info with messageDateField ? As far as i research, there is no way of adding the time support of messageDateField such that it can be enabled by setting a parameter to true like getTime="true". Thanks.
    Fatih ER

    Sebahattin,
    You can display the time component by adding the timeStyle attribute:
    <onSubmitValidater>
    <date dateStyle="shortish" timeStyle="short" />
    </onSubmitValidater>
    Unfortunately, in the current release, when you save the date, the time will be lost. We have fixed this for the next release. As a work around, you can continue the route you have chosen with a separate time field.
    To get the time value in your entity object you can add a transient attribute "time" to both your VO and EO. In the UIX page, you create a field with the same name and set persistent="true". Now, the JHeadstart save process will simply send the time field to your EO through your VO, and you can use it to add the time component to your date field.
    Steven davelaar.

  • HOW CAN I GET THE TIME IN EXCEL SHEET USING WRITE TO MEASUREMENT INSTRUCTION

    HI, I am using GET TIME IN SECONDS ,and after that i placed SECONDS TO DATE /TIME instruction ,and i had taken a write to measurement file instruction
    to get the time in excel sheet. Now i am not able to connect write to measurement source to seconds to date and time output . Is there any solution.
    I am attaching my VI file also.
    Attachments:
    TEST.vi ‏43 KB

    Hi
    Im using Labview 8.2. Currently it just shows the data without the time. Im not sure what to do. It works perfectly though. I just want the time to appear on my notepad along with my data
    holla
    Attachments:
    Testing1.txt ‏1 KB
    Untitled 231_LV80.vi ‏23 KB

Maybe you are looking for

  • How do I get my bookmarks off a damaged hard drive.

    My laptop hard drive will not boot but I can access all my files with an external drive. Where do I find all my bookmarks so that I can copy and save them before I restore and or reformat that hard drive? I don't want to lose them because I have too

  • Basic Doubts in Digital Signatures ES

    1) Revocation Checking : i read that the certifications will be checked(to see whether it has been cancelled) by checking the CRLs list. Where can i find this list? 2) What is the concept behind Long Term Validity in Digital Signatures ES. Please hel

  • Very slow running CUITs in both Visual Studio and Microsoft Test Manager

    I've tried the exact same test cases on another less powerful computer and it runs perfectly. However on one machine it runs very slow. It seems to take ages finding execute each step. Not sure what is going on. Help greatly appreciated.

  • Adobe Reader XI - print dialog box blank - Windows 8

    Using the latest version of Adobe Reader XI, The print dialog box either comes up blank as shown in file 1 and I have no control over printing. OR it comes up with all the labels missing, see File 2 - yet I can control some features by clicking on th

  • Bookmarks not saved

    I can't get my browser to bookmark anything. I can edit my previously saved ones, but new ones just don't happen. Yes, it's up-to-date, the latest update available. And yes, I went through the trouble shooter and reset firefox to it's original settin