TImezone calculations

I am using an Oracle 8.1.7 DB and trying to calculate the systems timezone within a PL/SQL function. Does anyone have any suggestions or sample code???
Thanks in advance

Here are 2 documents from Metalink:
1.
PURPOSE
The aim of this article is to give customers some possibilities when working in a world wide context.
SCOPE & APPLICATION
Replication , Sqlplus, SQL
TIMEZONES IN SQL*Plus
The common method to synchronize time when working in a worldwide context is to set the timezone within the Operating System, (OS). The Oracle database will inherit the timezone of the OS environment.But what will happen if the instance is located in Paris(GMT+1) and you want to submit a DML throught a dblink located in Tokyo (GMT+9)?
This can be achieved by using the SQL built-in function NEW_TIME.
NEW_TIME consists of 3 entries:
- the first one corresponds to a DATE/TIME in the local timezone
- the second one is the correponding timezone (eg. GMT, EST, etc.)
- the last one is the timezone in which the date will be converted
Below are the valid timezones used by NEW_TIME:
AST,ADT Atlantic Standard/Daylight Time (GMT-4/GMT-3)
BST,BDT Bering Standard/Daylight Time (GMT-11/GMT-10)
CST,CDT Central Standard/Daylight Time (GMT-6/GMT-5)
EST,EDT Eastern Standard/Daylight Time (GMT-5/GMT-4)
GMT Greenwich Mean Time
HST,HDT Alaska-Hawaii Standard/Daylight Time (GMT-10/GMT-9)
MST,MDT Mountain Standard/Daylight Time (GMT-7/GMT-6)
NST Newfoundland Standard Time (GMT-3.5)
PST,PDT Pacific Standard/Daylight Time (GMT-8/GMT-7)
YST,YDT Yukon Standard/Daylight Time (GMT-9/GMT-8)
As you will note, this list does not include all the timezones for the world.To use the NEW_TIME function with timezones, other than those listed, you will need to manipulate the current time via a sysdate function.
Example 1
Site A:Paris Site B Tokyo
dblnk1 pointing at siteB dblnk2 pointing at siteA
Site A is GMT+1 and Site B is GMT-9.
From SiteB with TZ(OS timezone set to GMT-9)
Suppose that it's 9:00 PM in Tokyo:
SQL> select sysdate from dual@dblnk2
Results in 9:00 PM
SQL> select NEW_TIME(sysdate+1/24,'HDT','GMT') from dual@dblnk2
Results in 1:00 PM which corresponds to the time in Paris.
This function is useful when INSERTING,UPDATING OR DELETING.
2.
Problem Description:
====================
In SQL, how do you add or subtract time increments, other than days, to a date?
Search Words: second, seconds, minute, minutes, hour, day
Problem Explanation:
====================
Example
How do you subtract 2 hours from SYSDATE?
Solution Description:
=====================
An Oracle date is in units of a day, so express the desired time interval as a fraction of a day.
o To add n day(s), add n to the date.
Example
SELECT TO_CHAR(hiredate+(n), 'DD-MON-YY HH:MI:SS') plusday
FROM emp;
o To add n hour(s), add n/24 to the date.
n hr x 1 day
24 hrs
Example
SELECT TO_CHAR(hiredate+(n/24), 'DD-MON-YY HH:MI:SS') plushour
FROM emp;
o To add n minute(s), add n/24/60 to the date:
n min x 1 hr x 1 day
60 min 24 hrs
Example
SELECT TO_CHAR(hiredate+(n/24/60), 'DD-MON-YY HH:MI:SS') plusmin
FROM emp;
o To add n second(s), add n/24/60/60 to the date.
n sec x 1 min x 1 hr x 1 day
60 sec 60 min 24 hrs
Example
SELECT TO_CHAR(hiredate+(n/24/60/60), 'DD-MON-YY HH:MI:SS') plussec
FROM emp;
Solution Explanation:
=====================
Example
To subtract 2 hours from SYSDATE:
1. Express 2 hours as a fraction of a day:
2 hrs x 1 day = 2 = 1 day
24 hrs 24 12
2. Use the following syntax:
SELECT SYSDATE - 1/12
FROM dual;
This returns the time 2 hours ago.
Maybe it will be a little help for you.

Similar Messages

  • Evolution-2.8 Displaying wrong Timezone

    Hi all,
    I've been seeing some weirdness with evolution-2.8 and timezones since the change on Sunday (EST to EDT).  I'm running against an exchange server for my calendar and mail.
    My system date is shows the correct timezone as EDT.  Evolution, however, does not seem to acknowledge the timezone change and shows its time wrong (red line in calendar is one hour behind).  Appointments are getting messed up with this as well.
    Has anyone seen a patch or know of a fix for this?  My system is current to today.
    Thanks
    Norm

    Update -- this is from the Evolution mailing list:
    Heya,
      Evolution uses it's opwn time zone data. Update Evolution package ,
    restart and check again.
    On Mon, 2007-03-12 at 19:31 -0400, Paul Smith wrote:
    > Something is weird.  I have my timezone set to America/New_York in
    > Evolution and on my system.  I'm using Ubuntu 6.10 with full updates,
    > with Evo 2.8.1.
    >
    > After the timechange on Sunday, my entire system had the right time,
    > EXCEPT Evolution.  The little red line in the Calendar was 1 hour
    > behind.
    >
    > I exited and restarted Evo, but that didn't help.  I logged out and back
    > in, and that didn't help.  I rebooted my system, and THAT didn't help.
    > My system clock and the clock on all apps I've checked is correct, but
    > Evo calendar still says it's quarter after 9am instead of quarter after
    > 10am.
    >
    > Is Evo using its own internal timezone calculations instead of the
    > system timezone for some utterly bizarre reason?  What could be causing
    > this?!?!
    >
    I'm up to date though -- where is the new update for this?
    Norm

  • Incorrect import folder dates

    Hi everyone,
    Enjoying using LR 1.0, but I have found one problem that I can't find details of in a search of the forum.
    When I import files Lightroom often creates folders with the wrong dates. For example, I took a series of around 60 shots between 10:30am and 11:10am on Saturday March 3rd. When I import the files I get them split between two folders. The first is 2007-03-03 and the second, coanting some of the later photos, is 2007-03-04. When I view the file metadata the dates are all correct.
    I am thinking this could be releated to time zones and UTC. I am in New Zealand and have my Windows time set to NZ timezone.
    Has anyone else encountered this? Any other thoughts or comments?
    Thanks,
    Stephen

    I'm not sure. At present we are on daylight savings time, so 11:10am here is actually 10:20pm UTC. It would make sense if it was after midnight. So I don't think it's actually UTC that is involved, but some other timezone calculation. I would expect that someone else (in this area of thwe world at least) would have experienced this.
    It's not really an issue since I don't like the "per day" import folders and would really like to be able to per month folders (like I do with Downloader Pro). I've logged a feature request in that part of the forum to be able to manipulate the folder names created during import using dates etc from the metadata.
    In the meantime I'm using "Import to one folder" and manually maintaining the current month as the folder name...

  • Task reminders and British Summer Time (GMT +1)

    I have Ovi Suite 2.1.1.1 and an E71.
    When I sync tasks with a reminder from Outlook, the reminder on my phone is one hour later.  Schedule items sync at the right time.
    I have selected GMT +1.00 on the phone as the time zone. 
    Something has obviously gone wrong with the timezone calculation as the phone doesn't realise that the time passed in from Outlook is already in British Summer Time (GMT +1) and goes ahead and adds an hour. However, it doesn't add an hour for schedule events....????
    Ta,
    Ed.

    Yes, the same problem using a Nokia E72 in Hungary. Reminders in Outlook 2007 are 2 hours earlier than on the phone. Very irritating! I'm using OVI Suite 2.1.1.1 on Win 7 (64-bit).
    Any help around?
    Kristof

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

  • Calendar All Day Events, Calculated Columns, Timezone and DayLight Savings - Issues

    Hi
    I have a calendar where I am trying to display in one column using a calculated field (TitleWithTimes):
    Start time (only display time) - End Time (only display time) : Title i.e. 00:00 - 23:59 : Test Event
    So I add an all day event to the calendar for this month (February), it appears correctly:
    i.e. 00:00 - 23:59 : Test Event 1
    I am based in the UK so my time zone is currently GMT/UTC.
    However if I add any all day events to the calendar in April when the time zone switches to GMT+1, the start and end times appear incorrect.
    i.e 01:00 - 00:59 : Test Event 2
    Field: TitleWithTimes
    =TEXT([Start Time],"hh:mm")&" - "&TEXT([End Time],"hh:mm")&" : "&Title
    This issue only occurs with ALL Day Events when the events are scheduled for a in the period of the year where the Time Zone becomes GMT + 1. My regional settings everywhere in SharePoint are correct as are all the SharePoint servers.
    I have done lots of searching and troubleshooting to try and resolve this issue but it appears nobody has found a reliable fix for this issue with calculated fields, all day events and time zones? Does anyone have any ideas of workarounds?
    Thanks

    Hi,
    I understand that you had issues about the calculated field in calendar.
    This is a reproducible issue, when creating an all day event, the calculate column based on the Start Time/End Time is different from the original column value. The date is stored in SQL in GMT time and is displayed in SP in the correct time in lists. So
    returning the start time in a calculated column for an all day event returns the start time in GMT time, which is not the current time most likely.
    As a workaround, you can regenerate the calculate column to add one day/minus one day based on whether the event is an all day event, or create a workflow to copy the start time column to your created date/time column.
    Here is a similar thread for your reference:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/27ab0bb0-245b-46ca-9f87-c0eb043653ef/date-formatting-in-calendars-returns-wrong-day?forum=sharepointgeneral
    Thanks,
    Linda Li
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • Displaying the result of a calculation in a dynamic text box

    Hi folks,
    I'm having a very minor issue here (operator error, I'm sure ). With the help of some folks here, I've created a series of calculations, and I've got that part down. Now, I just need it to show up in the movie.
    I've created the dynamic text box in Flash (CS3), but when I hit test, it won't show up.
    After all the calculations, I should have a figure that I call totalmoney. My dynamic text box is called total. The user doesn't need to hit anything for it to appear. It just appears as part of the movie.
    Here's my code:
    stop();
    var startDate:Date = new Date(2010,0,12);  // use your  startyear, startmonth, startdate in the new Date() parameters.
    var  currentDate:Date = new Date();  // assuming user's clock is correct and in your  timezone.  else use server date/time.
    var numberOfSeconds:Number =  (currentDate.getTime()-startDate.getTime())/1000;
    var interest:Number =  (numberOfSeconds*0.74356);
    var totalmoney:Number =  (interest+15,000,000);
    function displaytotal(evt:TextEvent):void {
         total.text = "totalmoney";
    Any thoughts?
    Thanks!
    Napo

    You didn't have to bury any of the calculations in the function--leaving it as you had it is better.  They could remain where they a=werew, and you'll probably find you want them outside it if you have other plans for using them.  If left inside, they only have scope inside.  In the programming world, it's good to think of functions as things that do one thing and one thing only (though it isn't often practiced that way)--it's called modular design.
    When you place an event as an argument for a function, it typically means that there is an event listener that initiates the call to the function.  If you work with buttons you'll see what I mean.  But if the plan is to create your own call to a function when you desire it as such, not have it driven by an event listener, then you don't need to pass any event to it, though you may pass some other type of variable to it if need be.
    For instance, what you have now will call the function without an argument because the function has the value built into its code....
    displaytotal();
    But you could also make the function a little more generic and set it up to recieve the value instead as an argument...
    function displaytotal(amt:Number):void {
         total.text = String(amt); // an earlier error of mine
    displaytotal(totalmoney);
    That would make your function a little more useful.  Now it could be used to display other Number variables as well.
    // my earlier error was that a textfield displays text, so you need to convert the Number value to s String.
    Hope I'm not confusing you.

  • ICal Timezone Selection and Naming

    A few OS revisions past timezones were named with some at times distant association to UTC standards and could be attached to an event. Type in Eastern Standard or just Eastern and up came timezones with that in their name. Simple right, if you knew the name of the timezone you were planning the event for? Seems reasonable, if you are scheduling events for different time zones you might, nay probably, knew the name of the timezone. Or could easily find it online.
    As I recall you could also type the name of a city like Cleveland or Stockton, or even some more obscure places like Vienna or Paris, and get the same results.
    Apple changed it, to remove any confusing references to actual standard timezone names when selecting, ahem, a timezone. Nor can you select by offset from UTC (0) known to most as GMT, which was also an available choice.
    One currently has to name a city or large town that Apple has deemed worthy of inclusion, and while shock of shocks the US database of cities, towns and hamlets is fairly well populated, those outside the US  appear to have been selected by a bored intern who snuck a bottle of beer in armed with a dart and a word map.
    Requiring one examine, from an example I prepared earlier, the map of Western Australia searching for a town that appears significant enough to perhaps have been included in said timezone popup menu by Apple that is also located near Grass Patch (look it up), and hopefully happens to be in the same timezone is an exercise in almost random guesswork. Take a look at a timezone map of Australia if you think they are all stacked neatly side-by-side with borders as straight and dull as a Texas town main street.
    I own a computer to avoid error inducing, repetitive, dull activities that could better be done by a well trained pidgeon. It is, obviously I suppose, very irritating and ironic that it was a desire to avoid such errors that was the reason one turned on timezone support in the first place.
    You also have to know in advance, or try possibilities at random, the name town or city hoping that it appears in the Apple town-or-city-name-apparently-chosen-at-f*****g-random-and-associated-with-a-tim ezone popup menu in your effort to select the same timezone as your event attendee. Proximity does not guarantee a town is the same timezone after all. Often a distant town or city in the Apple popup will be in the same timezone, while one nearby is not. But you cannot know for certain without trawling through the internet and wikpedia to work this out because most maps do not include delineations of the various timezones.
    In this case Apple has made a mistake in deciding what not to do. Removing a perfectly usable, well not perfectly but better than this, existing system in place as an option was an error.
    By removing standard UTC codes, or something approximating them (you know the international standard naming convention for timezones that has been abandoned in an application trumpeting its adoption of standards), instead of just leaving them available alongside the calendrical equivalent of Soma, may, may, have made the system easier for people unfamiliar with timezones. But I doubt it, it is more likely to guarantee continued ignorance based on increased confusion engendered by use of a system providing no pattern or framework for understanding the concept of timezones, and it is a pain in the rear for anyone else.
    It also is part of a trend previously only inflicted on Windows users routinely of attempting to make things simpler for more people while making it impossible or more difficult to someone who knows what they are doing. I have no objection to providing simpler alternatives, just stop taking away more elegant if intellectually "demanding" ones already in existence.
    Looking up what city is nearby in the hope it is on the magic list for every one horse town a client might live in instead of just being able to type one of the Australian UTC standard timezones as provided by the client, or pick an offset of +8 hours in the above example is patronising, absurd, time consuming, and prone to errors.
    Is there anyway I can use the terminal to edit the pop up list of time zones or substitute a different one referenced by iCal? Or to restore something resembling a standard pop up list ordered by offset from UTC 0, otherwise known as GMT? If I could simply pick an offset of -8, or +5 hours, as examples, life would be a lot happier in iCal. Because even if I have to determine some offsets, as in the WA example above, doing so is as simple as typing "What is the time in <insert name of obscure s******e here> <name of country here> in my browser bar and hitting Enter.
    Yes I know that means I may have to do addition or subtraction, but I have the Apple Calculator for anything over 2, and somehow it has been spared any attempts to simplify its use.

    I've had this same issue 2 times now (I'm also on the same setup as you).
    What has worked for me is the workaround listed here:
    http://www.macosxhints.com/article.php?story=20070313180838582
    To simplify, copy the script shown in the last post into a text file called:
    correctBirthdays (no file extension such as .txt is necessary)
    and save it into your home directory. Once you've done that:
    1. Back up your Address Book with the 'File > Back up Address Book...' menu item
    2. Open the Terminal application
    3. In Terminal, type *chmod 755 correctBirthdays* to make the script executable.
    4. Type *./correctBirthdays -1* and hit enter. If you're coming back from Japan, you'll want to use 1 instead of -1 to move the birthdays forward instead of back a day.
    5. That's it. Terminal will report how many birthdays were corrected.
    I'm guessing that this problem has been fixed in Mac OS X 10.5 Leopard, and that's why musicale can't reproduce the issue.
    Hope this helps!
    (and I take no responsibility if you mess something up! It should work though.)
    Rafael

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

  • EIM 4.3.1 - Where do you change the default timezone for reports?

    I have noticed when running reports that the default time zone always seems to be -5 Indiana (East). I have changed the business calendars under the departments but it does not seem to make any difference to the reports. Is there some where else this needs to be changed or is this some sort of bug?
    Thanks,
    Matt

    Matt the timezone is coming from the pc where you invoke the report, a saved report can be scheduled to run
    using a specific time zone, at run time or whilst creating a report your locale will be used to populate the time zone.
    Calendars do not drive report time zone and drives workflows and chat entry points. Time zone for logs and other calculation is based on the server time zone.

  • Date duration calculation in the BLS

    All,
    We are using MII 12.0.6
    I am looking at a very peculiar behavior while calcualting the date difference between 2 dates.
    For ex. the following expression: 
    (datediffminutes(datetoxmlformat("2010-3-21 14:06:30 ", "yyyy-MM-dd hh:mm:ss"), datetoxmlformat("2010-05-24 08:14:54","yyyy-MM-dd hh:mm:ss")))/60
    yields 1530.13 as the result(this is the correct evaluation) when tested from within the Link editor (clicking the evaluate button).
    Now saving this transaction and giving the value of the above expression to an output param followed by calling this trx from an Xacute query yields 1529.13 as the result (I hr difference than above).
    I have tested this with a few more dates going as far back as Dec 2009 yielding the same one hour difference.
    On the other hand for any start date in May 2010 yields a correct result even when called from an Xacute query.
    I tested this  in a 12.0.2 system and found this behavior absent as in all was working as expected.
    Has anyone come accross this before?Do you know if the latest patch has this fixed?
    Just to cross check can anyone giive this a try in their 12.0.6 or higher system and report back?
    Thanks a lot for your help.
    Kind Regards
    Udayan

    Hi Udayan,
    Please open a ticket.  It sounds like a bug, although a few years back there was a problem with one of the java packages and Daylight Savings Time.  If you search this forum for all time, you will find some of the postings. 
    Since there have been changes to when Daylight Savings Time start and ends, it is likely related and could possibly be java related instead of MII.  I doubt it, but it is possible. 
    Edit:
    A little more research turned up differences in how Daylight Savings Time is calculated in different countries/continents.  Coincidentally, the US started on March 14th this year while the European Union started on March 28th (this date sounds familiar).  Not sure what timezone, you are in, but you may want to play around with the timezone settings for your computer to see if the error is consistent with US vs European timezones (or wherever you happen to be located).
    [Daylight Savings Times around the world|http://www.worldtimezone.org/]
    Thanks,
    Mike
    Edited by: Michael Appleby on May 25, 2010 12:41 PM

  • Calculating Elapsed Time Is Off By One Hour

    I am fully aware of many topics discussed in the various forums here related to the OS timezone and DST settings impacting how the JVM will process date/time calculations. I am running on Windows XP Professional, and I have checked and double checked the timezone setting, it is correctly set to Central Time and the "Automatically adjust clock for daylight saving changes" checkbox is checked.
    The code found at the end of this message clearly shows the problem for which I have yet to find an explination. I intended to be able to use a timer to update a string to show how much time has elapsed since the start of anything for which I need to know this information. As you can see by the results (example of which is listed after the code), the timezone and DST offsets seem to be properly retrieved by the JVM, but if this is the case, then why is the elapsed time value off by one hour?
    I am looking for a solution/explanation involving the date/time classes, not a workaround whereby I end up extracting multiple time representation subsets and manipulating them myself. Any help will be greatly appreciated.
    * TestTimeZone.java
    * Created on September 12, 2004, 7:18 PM
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.text.*;
    * @author  Jared
    public class TestTimeZone {
        java.util.Date startDt;
        /** Creates a new instance of TestTimeZone */
        public TestTimeZone() {
         * @param args the command line arguments
        public static void main(String[] args) {
            new TestTimeZone().go();
        private void go() {
            startDt = new java.util.Date();
            TimeZone tz = TimeZone.getDefault();
            System.out.println("the default timezone is " + tz.getDisplayName(true, TimeZone.LONG));
            System.out.println("the default timezone ID is " + tz.getID());
            System.out.println("useDaylightTime = " + tz.useDaylightTime());
            System.out.println("default locale = " + Locale.getDefault().toString());
            javax.swing.Timer t = new javax.swing.Timer(1000, new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    java.util.Date currDt = new java.util.Date();
                    Calendar cal = Calendar.getInstance();
                    long elapsedTime = currDt.getTime() - startDt.getTime() -
                        (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET));
                    SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
                    System.out.println("Elapsed: " + formatter.format(new java.util.Date(elapsedTime)) +
                        " Start: " + formatter.format(startDt) +
                        " Current: " + formatter.format(currDt));
            t.start();
            while (true) try {
                Thread.sleep(10);
            } catch (Exception e) {
                e.printStackTrace();
    }And here is the result I am seeing:
    the default timezone is Central Daylight Time
    the default timezone ID is America/Chicago
    useDaylightTime = true
    default locale = en_US
    Elapsed: 23:00:01 Start: 00:03:57 Current: 00:03:58
    Elapsed: 23:00:02 Start: 00:03:57 Current: 00:03:59
    Elapsed: 23:00:03 Start: 00:03:57 Current: 00:04:00
    Elapsed: 23:00:04 Start: 00:03:57 Current: 00:04:01
    Elapsed: 23:00:05 Start: 00:03:57 Current: 00:04:02
    "

    Great. Now that we have gotten half way to the goal, please let me know how you intend to get that difference in miliseconds presented as a time value using any of the date/time classes Java has to offer. That way, I don't have to rewrite the code that puts it into a properly formatted String (the kind folks at Sun have already written that code). Using date/time classes to acheive this is what I attempted with my application. I added the milisecond adjustments for TZ and DST because if I didn't the reported elapsed time would be off by 6 hours, not just 1.
    I am open to all suggestions.

  • Timezone Conversion

    I have a file whose last modified date is in EST.
    I want to convert the time to CST.
    Can someone help?

    I have a file whose last modified date is in EST.No. The last modified date isn't in any TZ. It's just a point in time, an offest relative to 1/1/1970 00:00:00.000 GMT.
    I want to convert the time to CST.You mean you want to display that instant in time in CST.
    import java.text.*;
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
    df.setTimeZone(TimeZone.getTimeZone("CST");
    String dateStr = df.format(date);
    Calculating Java dates: Take the time to learn how to create and use dates
    Formatting a Date Using a Custom Format
    Parsing a Date Using a Custom Format

  • Compare two dateTime with different timezone

    HI, All,
    I found a strange thing when compare two dateTime in BPEL;
    In my BPEL process, client passed a date time to the process , and the process compare the date time with current data time.
    1.client pass cutoffDate to process
    2. in a switch activity, I compare cutoffDate with current date. code:
    bpws:getVariableData('cutoffDate')<=xpath20:add-dayTimeDuration-to-dateTime()
    but seems this compare ignored the timezone information.
    For example:
    cutoffDate=2010-03-05T06:17:38.838+00:00
    currentDate=2010-03-05T14:10:38.838+08:00 this time =2010-03-05T06:10:38.838+00:00
    but cutoffDate<currentDate == true... seems it ignored the timezone info..
    This is a bug or I used a wrong compare function?
    Thanks.
    Edited by: Colin Song on Mar 5, 2010 3:28 PM

    Hi Colin,
    Please go through below link, there is topic about calculating difference between dates. Hope you find solution.
    http://blogs.oracle.com/reynolds/2007/07/19/
    Please let me know, if still not successful.
    Thx,

  • Timezone to IST

    Hi All,
    How can I convert the standard time zones like EST,MST, EDT in to IST(Indian Standard Format)?
    Thanks in advance.
    Regards,
    Ram.

    SELECT SYS_EXTRACT_UTC(SYSTIMESTAMP) + (5.5/24)  from dual;Similar post on timezone conversion : Re: Difference calculation Indian and Irish time.

Maybe you are looking for

  • How to allow users to edit form

    Maybe this isn't a typical use for these forms, but I thought I would give it a try.  I need to create product specification forms for my designers to fill out to give to their clients.  There are standard fields in the form such as product informati

  • Help with : oracle.ewt.scrolling.scrollBox.ScrollBox

    I want to show a ScrollBox in a VBean area. How do I tell the ScrollBox that I want to wrap the lines instead of using a vertical scrollbar, just a horisontal scroolbar. I set it up like this. scrollpane = new ScrollBox(Pane, scrollpane.DISPLAY_NEVER

  • Set table location

    Post Author: midav CA Forum: Data Connectivity and SQL Hi, CR 8.5 had   a menu option where one could manually modify table location from [db_name].[owner].table_name to just table_name by deleting [db_name].[owner] prefix which would make your repor

  • Nano USB 2.0 Problem

    Hi, I'm having a trouble with my Nano. I have 2 Nanos and a MB Asus P4SE/U2 with 2 USB 2.0 ports. When I first conected my Nano it apeared a message saying "This device can be faster if you use a USB 2.0 port" or something like that. I have 2 USB 2.0

  • Convert XML to OTF

    Hi All, Can anybody please give the Function Module or Class to convert XML formatted data into OTF fotmat. This is very urgent.Please .I will give you reward points. Thanks, Swapna.