Specific time in different timezones

Hello all,
I have the following scenario. My developement pc is in a PDT timezone and my server is in a EDT timezone. Plus, the date entries in the server need to be GMT values.
I know that, right now at least, there are 3 hours of difference between PDT and EDT, and 4 hours of difference between EDT and GMT.
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat timeDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss, z");
        Date date = calendar.getTime();
        System.out.println("server:\t" + timeDateFormat.format(date));
        timeDateFormat.setTimeZone(TimeZone.getTimeZone("EST5EDT"));
        System.out.println("local:\t" + timeDateFormat.format(date));
        timeDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        System.out.println("GMT:\t" + timeDateFormat.format(date));output:
server:     2007-11-02 11:15:43, PDT
local:     2007-11-02 14:15:43, EDT
GMT:     2007-11-02 18:15:43, GMT
Now, I need to convert today's midnight time (EDT) to GMT from my pc having PDT timezone.
        SimpleDateFormat timeDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss, z");
        String today = "2007-11-02 00:00:00, EST5EDT";
        Date date = timeDateFormat.parse(today);
        System.out.println("server:\t" + timeDateFormat.format(date));
        timeDateFormat.setTimeZone(TimeZone.getTimeZone("PST8PDT"));
        System.out.println("local:\t" + timeDateFormat.format(date));
        timeDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        System.out.println("GMT\t" + timeDateFormat.format(date));output:
server:     2007-11-02 00:00:00, EST
local:     2007-11-01 22:00:00, PDT
GMT:     2007-11-02 05:00:00, GMT
1. Why does it show EST instead of EST5EDT or just EDT?
2. Why there are now 2 hours of difference between EDT (EST) and PDT? I think it's related to 1.
I'm pulling my hair out of my head with this one. I'd really appreciate any comments on this. Thanks

fun1asma wrote:
Today Nov 5th, my code is working fine. My problem is obviously related to the daylight saving time. Since I seem to be using a recent Java Platform (1.5.0_11), does this mean that DST are not fully supported by SimpleDateFormat?As far as I know, Java 1.5.0_11 supports the TZ rules in the U.S. as they exist now. It's possible that there's a bug in that support. It may also be that Java is using your OS's notion of TZs and your OS may not be up to date. I forget the exact rules as to when Java uses its own TZ rules vs. those of the OS.

Similar Messages

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

  • Calculating time for different timezone, problems with daylight savings?

    Hi all,
    I try to convert my locale time to a different timezone (like a world clock does). This worked until Europe got "summer time". Then my time calculation went wrong. I just paste the following coding to give you a quick reproducable code.
    I did a lot of googleing but nothing found so far. Also search here in the forum didn't help me solving it. So now I created a post on my own.
    The output of the Java programm is the following (without the colored comments). I just entered these comments to show you where the calculation is right and where it goes wrong.
    I have absolutely now idea about where the chase the error. I am only guessing with "daylight savings issue".
    Hopefully anybody has a good idea.
    Thanks in advance
    John
    Europe/London {color:#339966} *(correct calculation!)*{color}
    daylight shift in millis: 3600000
    Is in daylight savings: true
    19.04.2010 11:28:53
    *Europe/Berlin {color:#339966}(correct calculation){color}*
    daylight shift in millis: 3600000
    Is in daylight savings: true
    19.04.2010 12:28:53
    Australia/Sydney{color:#ff0000} (wrong calculation, shoul 1 hour){color}
    daylight shift in millis: 3600000
    Is in daylight savings: false
    *19.04.2010 20:28:53*
    America/New_York {color:#339966}(correct calculation){color}
    daylight shift in millis: 3600000
    Is in daylight savings: true
    19.04.2010 06:28:53
    Asia/Bangkok {color:#ff0000}(wrong calculation, shoud 1 hour){color}
    daylight shift in millis: 0
    Is in daylight savings: false
    19.04.2010 17:28:53
    Asia/Hong_Kong {color:#339966}(correct calculation){color}
    daylight shift in millis: 0
    Is in daylight savings: false
    19.04.2010 18:28:53
    package test.timezone;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.TimeZone;
    public class TZCalc {
    public static void main(String[] args) {
    List<TimeZone> list = new LinkedList<TimeZone>();
    list.add(TimeZone.getTimeZone("Europe/London"));
    list.add(TimeZone.getTimeZone("Europe/Berlin"));
    list.add(TimeZone.getTimeZone("Australia/Sydney"));
    list.add(TimeZone.getTimeZone("America/New_York"));
    list.add(TimeZone.getTimeZone("Asia/Bangkok"));
    list.add(TimeZone.getTimeZone("Asia/Hong_Kong"));
    for (TimeZone tz : list) {
    Calendar cal = new GregorianCalendar(tz);
    SimpleDateFormat formatter = (SimpleDateFormat) DateFormat
    .getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    formatter.setTimeZone(tz);
    System.out.println("\n"  +tz.getID());
    System.out.println("daylight shift in millis: "  tz.getDSTSavings());
    System.out.println("Is in daylight savings: "  tz.inDaylightTime(cal.getTime()));
    System.out.println(formatter.format(cal.getTime()));
    }Edited by: jbegham on Apr 19, 2010 3:46 AM
    Edited by: jbegham on Apr 19, 2010 3:47 AM

    You should not set the time zone on the calendar since you want the calendar based on UTC.
            List<TimeZone> list = new LinkedList<TimeZone>();
            list.add(TimeZone.getTimeZone("Europe/London"));
            list.add(TimeZone.getTimeZone("Europe/Berlin"));
            list.add(TimeZone.getTimeZone("Australia/Sydney"));
            list.add(TimeZone.getTimeZone("America/New_York"));
            list.add(TimeZone.getTimeZone("Asia/Bangkok"));
            list.add(TimeZone.getTimeZone("Asia/Hong_Kong"));
            Calendar cal = new GregorianCalendar(); // Regardless of your timezone this holds the number of milliseconds since 1/1/1970 UTC.
            for (TimeZone tz : list)
                SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
                formatter.setTimeZone(tz);
                System.out.println("\n" + tz.getID());
                System.out.println("daylight shift in millis: " + tz.getDSTSavings());
                System.out.println("Is in daylight savings: " + tz.inDaylightTime(cal.getTime()));
                System.out.println(formatter.format(cal.getTime()));
            } I have no idea whether or not this then gives the results you expect.

  • Posted and Edited time in different Timezones?

    I did a quick search but couldn't find anything, but this seems like a bug.
    From this thread:
    How to drop a index
    I noticed the Posted time is displayed in my timezone but the edited time is displayed in the other user's timezone. Not a big deal but it's just a bit odd.

    Nice catch rkhtsen
    That's because the posted time is saved as Timestamp in database while Edited message is in-printed as text while user hit Edit button. So it's in that user's timezone date.
    Edited by: yingkuan on Sep 18, 2008 3:41 PMI usually suppress that edit message by unchecking the Add message button.

  • Best way to manage date/time variables across different timezones

    I have an application that relies heavily on time accuracy. At the moment everything is fine, but soon the system will service customers across multiple timezones. The default behavior of the Date class is to show dates related to the current timezone, is there an easy way (setting) to override this behaviour? The system should show the time entered regardless of the timezone it was entered on.
    I use CF 8 for the back-end, and MySQL 5.1 to store data. The front-end is Flex 3/Air 2.
    I have looked everywhere, and things like saving dates as strings, or long ints, but if possible, I'd like to find a solution that does not involve dramatic changes to my database/code.

    Thanks for your reply, UbuntuPenguin,
    Your explanation is correct and what I'm trying to find out is an easy way to override that behaviour.
    As an example of what the issue is, let's say an event was entered here, in Toronto,ON, at 3pm, if a customer in Arizona sees the time, he/she will call us immediately to inform us that the event it's supposed to happen at 3pm, and not at 12pm (time that they see with the different timezone).
    As far as I've seen, the "best" way to approach this issue is by using  the transient tag during data transfer and compensate for the time  difference in the client timezone vs the selected "system" timezone  using getters/setters, but that implies storing the wrong date/time and  locking the system into one timezone, and it's just a hack that may  bring undesirable consequences in the future.

  • I enter specific times on the computer icloud calendar and the times are three (3) hours different when viewed on my iphone. I have checked the time settings on the iphone and it is correct (EST).Where do I go next?

    I have entered dates and specific times on my computers icloud calendar.  When I view the dates and times on my iphone the times are three (3) hours later. I have checked the time zone settings on my iphone and it is correct (EST).  Where do I go next?

    Restoring is the answer. It sounds as if there is a rogue process constantly draining your battery.
    The issue you face is that, if you restore your backup thereafter, you risk the problem coming straight back with your files.
    Store your files individually and it is time to start fresh.

  • Locale specific time

    Hi Readers,
    Pls., helpout ! am trying to get the current date and time depending upon the Locale object.
    Its known that depeding upon the timezone with particular Locale we can get the specific time particuler that Locale and timezone.
    I need to provide an API where user this as
    public String getCurrentDateTime1(Locale alocale, String pattern) { }
    mine cincern is how to get hte timezone as per the lOcale object passed.
    Mine current implimentation is like this where am getting same system time
    public String getCurrentDateTime1(Locale alocale, String pattern)
    //Calendar now = new GregorianCalendar(alocale);
    Calendar now = Calendar.getInstance(alocale);
    java.util.Date localeDate = now.getTime();
    SimpleDateFormat formatter = new SimpleDateFormat (pattern);
    String dateString = formatter.format(localeDate);
    return dateString;
    Can any body help to get the corresponding timezone to locale passed.

    How to get the timezone from the locale object
    passed, is it possible to do so or any alternative
    ways to get the timezone as per locale.There is a locale named Locale.US. Find out what it represents. Next, find out how many different timezones there are in that place. Are there more than one? If so, what does that tell you about the answer to your question?

  • I am looking for an iPad App that will play a specific iTunes song, at a specific time, on a specific day?  Thank you all!

    i am looking for an iPad App that will play a specific iTunes song, at a specific time, on a specific day?  Thank you all!

    Sorry, i did not say that i need to go out further than 1 week.  This is for a church Bell Tower Music System.  So we don't want to have to re program the music every week.  We are looking for more of a Calender App that will play iTunes Songs for alarms...different songs, on different days.  IDEAS ANYONE ???

  • How to set a specific time zone for time channel in DIADEM

    Hi,
    I'd like to know how to autmatically set a specific time zone for time channels in DIADEM.
    For example, I have stored data with corresponding time channel in UTC time on a disk which was collected in another time zone. Now I want to analyze this data and I want the time channel to show the local time in the time zone where the data was collected, and not the time in the local time zone where the computer is located.
    The time channel should also take site local summer/winter time into account. Now I'm running a script that handles it for me which adds or subtract hours according to my input. The problem is that I'm handling data from several different time zones and I'm not located in any of them and when you're running a lot of data over a greater time period, it's easy to make mistakes, especially when it comes to summer/winter time. Is there a any clever solution to this already implemented in Diadem that I have not found? 

    Hi hj77,
    No, I'm sorry, DIAdem has no time zone functionality at all.  I'm afraid you have no choice in DIAdem but to keep running your scripts.  Summer and Winter time are truly tricky, because the rules for when the changes occur are different in different countries and states within countries and also can change from year to year within the SAME country (as they did in the US a few years ago).
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • EA6100 AC1200 Blocking Guest internet access during specific times?

    I see that you can disable guest internet access for specific times but only for specific devices. What I want to do is turn off Guest access for all devices during specific times. 
    I am using this in an environment  where I will have different guests at different times with different devices and can't go in to block each one each time. 

    I think your only option at this time is to manually disable the Guest Wireless network when wanted.
    Please remember to Kudo those that help you.
    Linksys
    Communities Technical Support

  • Issue with Java date when different timezone involved

    Hi
    I am facing a problem with java util and SQL date due to different time zones,
    We have a applet which displays data as gant chart( microsoft project type)
    We have our server in NY (EST) which reads data from database (in EST) and sends this data to applet using applet-servlet communication (seralize object)
    This applet gets this date from servlet, does some calculation for pixcels and paints it, but now i am having problem with this calculation, since the date coming is from EST and calendar object in applet is from CST.
    How do i resolve this
    Ashish

    How are you passing the date or doing the calculation?
    I guess you're not using java.util.Date because then would have no problems. The Date class already accounts for different timezones; an instance represents a single moment of time which can be rendered differently depending on the time zone.

  • Shopping cart Creation Time is different from system time

    Hi ,
    Shopping Cart Creation Time is Different from System time.
    Could you tell me,        to which time it is refering to.
    How to change it.
    Create By is      webseruser
    Where can I find the required settings for the same
    Thanks In advance

    Hello,
    Are you checking this in BBP_PD?
    If you go to SU01 and check parameter "Personal Time Zone" -> "of the user", this time will appear to end user when creating document (document header in web).
                                                                                    If you do not have informed any value, it will be populated the pattern system timezone, defined in SU01 as well.
                                                                                    - I created a RFX in my test system with a user who's timezone (in tx SU01) is set as:
    Sys. Time Zone     CET                                                                 
    of the User        INDIA                                                                               
    - CET time  was 20:01:55                                                              
    - GMT time was 18:01:55                                                              
    - India time was 23:31:55                                                                               
    Looking at this RFX in BBP_PD I see the following:                                     
    Same user (India timezone and CET as "Sys. Time Zone"):                                
    Created_At: 20:01:55                                                                   
    Changed_at: 20:01:55                                                                   
    DETAILS (header):
    Created at: 18:01:55                                                                   
    Changed at: 18:01:55                                                                   
    RFX header (description): 23:31:55                                                     
    So, for end users, you should populate field "of the user" in SU01.
    In BBP_PD header details, you will have the GMT time (which is stored in internal tables).
    In BBP_PD created_at and changed_at you will have the system time zone, as defined in SU01.
    Regards,
    Ricardo

  • Setting a specific time for a "hold?"

    Is there a way for me to set a SPECIFIC time for a "hold?" CNTRL+D gives me a duration of an effect, but I can't seem to do the same after I add a "hold." Instead, I have to MANUALLY slide the handle of the red "hold bar" until I achieve my desired length. (Which, if your trying to match in a connected clip can be a little unscientific.)
    To that end, is there a way to "copy" a hold effect? (Currently, if I copy a clip with a hold, it copies the clip, but not the "hold." Nor does "paste effects" seem to work.)

    In Mac OS X Lion, it's iCal > Preferences > Advanced > check Turn on Timezone Support
    In iOS 5, it's Settings > Mail, Contacts, Calendars > TIme Zone Support > on
    The start and end time are in the same zone (and that's the zone associated with the event), but iCal automatically adjusts the entry to local time in the daily and related views.  There isn't a way to have a unique timezone for the start- and the end-time in a single event.

  • DB Back to a Specific Time with Archive Logs (Until cancel or time?)

    I'll try to be as clear as possible with my intended goals and the limitations of the system I'm working with:
    1. We have a test instance of our Oracle DB that I would like to be able to refresh with data from the production instance at any time, without having to shut down the production database or put tablespaces into hot backup mode.
    2. Both systems are HP Itanium boxes with differing numbers of CPUs and RAM. Those differences have been taken into account in the init.ora file for the DB instances.
    3. The test and production instances are using a SAN to hold the following file systems: ora_redo1, ora_redo2, ora_archlog, oradata10g. The test instance is using SAN snapshots (HP EVA series SAN) of the production file systems to pull the data over when needed. The problem is that the only window to do this is when the production system is down for nightly maintenance which is about a 20 minute period. I want to escape this limitation.
    What I've been doing is using the HP SAN to take snapshots of the file systems on the production system mentioned above. I do this while the production DB is up and running. I then import those snapshots into the test system, run an fsck to ensure file system integrity, then start up the Oracle instance as follows:
    startup mount
    Then I run the following query I found on line to determine the current redo log:
    select member from v$logfile lf , v$log l where l.status='CURRENT' and lf.group#=l.group#;
    Then I attempt to run a recovery as follows:
    recover database using backup controlfile until cancel;
    When prompted, I enter the path to the first of the current redo logs and hit enter. After waiting, sometimes it says that the recovery completed, other times it stops saying there was an error and that more files are needed to make the DB consistent.
    I took the above route because doing a recover until time (which is what I really want to do) kept prompting me for the next archive log in sequence that didn't yet exist when I took the SAN snapshot. Here was my recover until time command:
    recover database until time 'yyyy-mm-dd:hh:mm:ss' using backup controlfile;
    What I would like to do is take the SAN snapshot and then recover the database to about a minute before the snapshot using the archive logs. I don't want to use RMAN since that seems to be overkill for this purpose. A simple recovery to a specific point in time seems to be all that is needed and I have archive logs which, I assume, SHOULD help me get there. Even if I have to lose the last hour's worth of transactions I could live with that. But my tests setting the specific time of recovery to even 12 hours earlier still resulted in a prompt for the next, non-existent archivelog.
    I will also note that I even tried copying the next archive log over once it did exist and the recovery would then prompt me for the next archive log! I will admit right now that I really don't know a whole lot about Oracle or DBs, but it's my task to try and make it possible to "refresh" the test DB with the most recent data with no impact on the production DB.
    The reason I don't want to use hot backup mode is that I don't know the DB schema other than there are probably 58 or more tablespaces. The goal is to use SAN snapshots for their speed instead of having to take RMAN files and copy them to the test instance. I'm sure I'm not the only person who has ever tried this. But most of what I've found on line refers to RMAN, hot backup mode, or down time. The first two don't take advantage of SAN snapshots for a quick swap of all the Oracle file systems and I can't afford downtime other than that window at night. Is there some reason that the recover to time didn't work even though I have archive logs?
    One final point. The recover until cancel actually worked a couple of times, but it seems to be sporadic. It likely has something to do with what was happening on the production DB when I created the SAN snapshots. I actually thought I had a solution with recover until cancel last week until it didn't work three times in a row.

    I haven't completely discounted it but it seems like I would need to back up to files, then restore from files. I don't want to do that. I want a full file system level SAN snapshot that I can just drop into place. The does work when the production base is shut down. However, considering that I do have archive logs, shouldn't it be possible to use them to recover to a specific scene without having to do an RMAN backup at all? It seems that doing an RMAN backup/recovery would just make this whole process a lot longer since the DB is 160 gigs in size (not huge, but the dump would take more time than I would like). With a SAN snapshot, if I can get this to work, I'm looking at about a 15-20 minute period of time to move the production DB over to test.
    Since you are suggesting that RMAN may be a better approach I'll provide more details about what I'm trying to do. Essentially this is like trying to recover a DB from a server that had its power plug pulled. I was hoping that Oracle's automatic recovery would do the same thing it would do in that instance. But obviously that doesn't work. What I want to do is bring over all the datafiles, redo logs, and archive logs using the SAN snapshot. Then if possible use some aspect of Oracle (RMAN if it can do it) to mount the database, then recover to a specific time or SCN if using RMAN. However, when I tried using RMAN to do it, I got an error saying that it couldn't restore the data file because it already existed. Since I don't want to start from scratch and have RMAN rebuild files that I've already taken snapshots of (needless copying of data), I gave up on the RMAN approach. But, if you know of a way to use RMAN so that it can recover to a specific incarnation without needing to runm a backup first, I am completely open to trying it.

  • Storing location specific time in Database

    I have a requirement to store Location Specific Time in Database.
    Our Database Servers and OC4J run with US Central timezone. This causes all the "Date" mappings in my Entity to be stored in US Central timezone.
    My Entity
    StopId-----------------PickUpDateTime-----------------LocationId
    As per above structure "PickUpDateTime" is a DATE type field and i want to store Date and Time value as per Location id. I have a utility to get TimeZone from "LocationId".
    So If "LocationId" represents "New York", i want to see Time in Eastern Timezone.
    For example, "PickUpDateTime" is 2 PM Central, i want to see 3 PM in the Database.
    I was not able to use "Timestamp with Timezone" and in some cases we have to use "DATE" type in our Database Table. How can i achieve this?
    Chandresh

    Hi Folks, Hopefully this will be a simple one for
    you.
    I need my store method of my Database
    class to take only a Record object as a
    parameter. How can I use an if statement to do
    the check? Any help would be greatly appreciated.
    Cheers, LBCheck what?
    How does a Record know how to store itself?
    Does a Record map 1:1 to a table, or are there JOINs involved?
    public class Database
        void store(Record record)
            record.store();
    }Your question is too general and vague.
    %

Maybe you are looking for

  • Setting a default location of the 'Save As' dialog box

    I know this is an unusual question, but I do a lot of file-naming at work with Adobe Standard and it would help me if I could set a default location of the 'Save As' dialog box -- say, by dragging it to the corner of the screen so that the next time

  • Trying to Copy Home Movie DVDs

    I create all of my company's training DVDs. Accordingly, a co-worker has asked me to copy some DVDs of home movies he has. To my knowledge there are no copyright issues. Is there a way I can copy these using FCE/IDVD or disk utlity?

  • Normal GL planning upload

    Hi, We are not activated new GL. but we need to upload plan values against expenses and revenues. We need to upload the same by Period wise and GL wise through tcode FSE5N. But FSE5N is not flexible to upload period wise and GL wise. Can anyone guide

  • Recycle Bin when deleted

    Hi I discovered one strange thing at one of my costumers, we enabled AD recycle bin a year ago when we were running Windows 2008 R2 all good :-) Two weeks ago I replaced the 2008 R2 DC's with 2012 R2 DC's and today I discovered that the "when deleted

  • Iphone 5s robado y desvinculado de iCloud, ¿bloquearlo por IMEI?

    Hola, me han robado mi iphone 5s y lo han desvinculado de iCloud, ¿podria bloquearlo por IMEI?