Conversion from Date to say Locale time

Hello All,
I receive a date in xml file as a string. eg 01/27/2004 . I have to convert it to Locale format(2005-01-10T12:30-04:10) using XSL. Is it possible ?. If yes how to do that ?.
Thanks and regards,
Sachin

Hello All,
I am very sorry for framing the question wrongly. Actually I have recieved the date and time from xml which I will concat and store it in <xsl:variable>. Now I want to do processing on the variable using Java. Is it possble to do so ?. Means can I call some java function and pass the variable to the function do the processing on the variable and return the output and save that output in some variable which can be displayed.
Thanks in advance.
Waiting for reply.

Similar Messages

  • Implicit Conversion from data type sql_variant to datetime is not allowed.

     Getting a odd error. This code was working perfectly before a SQLServer upgrade.
    The linked database is working, I'm able to pull up data from it in separate queries just fine.
    I'm getting the following error.
    Implicit conversion from data type sql_variant to datetime is not allowed. Use the CONVERT function to run this query.
    Invalid column name 'TotalDay'. (.Net SqlClient Data Provider)
    can anyone spot the issue? I've tried sever variations of the same code, but still get the same thing.
    If I put this section in a query by it self it works just fine.
    ( DATEDIFF(ss,
    CONVERT(VARCHAR(10),( SELECT TOP ( 1 )
    TimeDate
    FROM [nav].AcsLog.dbo.EvnLog AS X3
    WHERE UDF2 = E.No_
    AND CONVERT(VARCHAR(10), X3.TimeDate, 101) = CONVERT(VARCHAR(10), @sdate, 101)
    ORDER BY TimeDate ASC
    ),101),
    CONVERT(VARCHAR(10),( SELECT TOP ( 1 )
    TimeDate
    FROM [nav].AcsLog.dbo.EvnLog AS X4
    WHERE UDF2 = E.No_
    AND CONVERT(VARCHAR(10), X4.TimeDate, 101) = CONVERT(VARCHAR(10), @sdate, 101)
    ORDER BY TimeDate DESC
    ),101)) ) AS TotalDayBadge ,

    >ANDCONVERT(VARCHAR(10),X3.TimeDate,101)=CONVERT(VARCHAR(10),@sdate,101)
    It is not a good idea to use string dates for predicates in WHERE clauses.
    Use DATETIME or DATE in predicates.
    If you are not interested in the time part of DATETIME, use DATE datatype.
    Example:
    SELECT CONVERT(DATE, getdate());
    -- 2014-08-25
    Datetime conversions:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Between dates:
    http://www.sqlusa.com/bestpractices2008/between-dates/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Disallowed implicit conversion from data type datetime to data type timestamp

    Received error: [Macromedia][SQLServer JDBC
    Driver][SQLServer]Disallowed implicit conversion from data type
    datetime to data type timestamp, table 'myTbl', column 'duration'.
    Use the CONVERT function to run this query.
    I have a field named duration hh:mm:ss.lll that I am trying
    to insert into MS SQL. DB has field defined as [duration]
    [timestamp] NOT NULL,
    My insert has this: INSERT INTO myTbl( duration) VALUES(
    <cfqueryparam value="2006-05-26 11:12:13"
    cfsqltype="CF_SQL_TIMESTAMP"/> )
    Why does this not work? rrrrrrrrrrrrrr! BTW: also tried with
    seconds as 13.111 which did not work. Does the db duration need to
    be date? I just want to store a duration for the time of a movie...
    10 Q

    quote:
    Originally posted by:
    quiet1
    Received error: [Macromedia][SQLServer JDBC
    Driver][SQLServer]Disallowed implicit conversion from data type
    datetime to data type timestamp, table 'myTbl', column 'duration'.
    Use the CONVERT function to run this query.
    I have a field named duration hh:mm:ss.lll that I am trying
    to insert into MS SQL. DB has field defined as [duration]
    [timestamp] NOT NULL,
    My insert has this: INSERT INTO myTbl( duration) VALUES(
    <cfqueryparam value="2006-05-26 11:12:13"
    cfsqltype="CF_SQL_TIMESTAMP"/> )
    Why does this not work? rrrrrrrrrrrrrr! BTW: also tried with
    seconds as 13.111 which did not work. Does the db duration need to
    be date? I just want to store a duration for the time of a movie...
    10 Q
    Duration as a timestamp? How odd, most people would store it
    as an integer. Or, if you want to build your own string, the syntax
    is {ts 'yyyy-mm-dd hh:mm:ss'}. The seconds might not be required.
    In any event, use createodbcdatetime() for the value you want
    to put into your table.

  • Conversion from DATE to TIMESTAMP datatype

    Hello,
    My issue is as follows:
    1. I have one variable of type DATE, which I assign the value of SYSDATE
    mydatevar DATE:= SYSDATE;2. I want to find *"today"*, truncated to DAY
      TRUNC (mydatevar, 'DD')
    TRUNC function returns DATE datatype. So I will receive in point 2 for example *'2010-01-13 00:00:00'*.
    3. I want to assign the value from point 2 to a variable of type TIMESTAMP
      mytimestampvar TIMESTAMP := mydatevar;which implicitly will convert the DATE variable to TIMESTAMP.
    Problem: During the conversion (both implicit and explicit conversion with a format mask) I lose the "00" hours and "00" minutes and receive something like this: "10-JAN-13 *12*.00.00.000000000 AM".
    Question: How can I convert from DATE to TIMESTAMP keeping hours and minutes zeros?
    Why I need this conversion: I have a table with a column "column1" TIMESTAMP(0) and I would like to take only those rows from the table, where "column1" is in range from today 12 o'clock in the morning till now (whatever hour it is).
    NLS characteristics of the database:
    PARAMETER                           VALUE
    NLS_LANGUAGE                           AMERICAN
    NLS_TERRITORY                   AMERICA
    NLS_CURRENCY     $
    NLS_ISO_CURRENCY                    AMERICA
    NLS_NUMERIC_CHARACTERS     .,
    NLS_CHARACTERSET                    AL32UTF8
    NLS_CALENDAR                            GREGORIAN
    NLS_DATE_FORMAT                    DD-MON-RR
    NLS_DATE_LANGUAGE            AMERICAN
    NLS_SORT     BINARY
    NLS_TIME_FORMAT                     HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT             DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT     DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                             BINARY
    NLS_LENGTH_SEMANTICS               BYTE
    NLS_NCHAR_CONV_EXCP             FALSE
    NLS_NCHAR_CHARACTERSET     AL16UTF16
    NLS_RDBMS_VERSION             10.2.0.4.0Session parameters are the same.
    DBTIMEZONE is "+02:00".

    Verdi wrote:
    Problem: During the conversion (both implicit and explicit conversion with a format mask) I lose the "00" hours and "00" minutes and receive something like this: "10-JAN-13 *12*.00.00.000000000 AM".I don't think you are necessarily losing any information whatsoever. It's probably more of a function of your NLS_TIMESTAMP_FORMAT and NLS_DATE_FORMAT. For example your NLS_DATE_FORMAT could be setup by default for a HH24 (24 hour time) which would report midnight as "00" hours. However, it looks like your NLS_TIMESTAMP_FORMAT is setup with a "HH" format with a meridian indicator which means 12 hours time.
    Your comparisons should be using date/timestamp data types anyways so as long as the input value is converted properly into a date type this shouldn't matter anyways.
    You can see what is actually stored by using the DUMP function:
    SQL> SELECT  DUMP(TO_TIMESTAMP(TO_CHAR(TRUNC(SYSDATE,'DD'),'MM/DD/YYYY HH:MI:SS AM'))) AS TSTAMP
      2  ,       DUMP(TRUNC(SYSDATE,'DD')) AS DT
      3  FROM DUAL
      4  /
    TSTAMP                                                                      DT
    Typ=187 Len=20: 218,7,1,13,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0                  Typ=13 Len=8: 218,7,1,13,0,0,0,0As you can see the TSTAMP and DT store nearly the same values (218,7,1,13), but the TSTAMP has more precision because of fractional seconds.
    HTH!
    Edited by: Centinul on Jan 13, 2010 7:23 AM

  • How to change timezone in B2B to reflect date fields per local time in DB

    Hi,
    I am in EST zone and I could see the data in database with date columns having time in PST. One of my transaction just errorred , I could see from B2B user interface tool error report message date time as 2:14 EST, while when I check the database values from TOAD the value is 11:14, which indicates there is some setup which might have caused to update Pacific Time in the database, I am not sure what could be the setup. Can anyone please indicate or provide inputs on what could be the cause and how to set up the application so that the date type data is updated with local time in database.
    Thanks
    Sachin Sutar

    Hi Sachin,
    We store the message using the database time. It seems like the database time zone is set to PST. To change it to a different time zone, please follow the instructions on this link:
    http://www.oracle.com/technology/products/oracle9i/daily/may02.html
    Hope this helps,
    Eng

  • Conversion from date to number & display a date in a textfield

    I Have 2 issues
    The first one:
    I need to extract the hour from a date variable.
    This is the code I already have:
    NUM_TOT := NUM_TEL + to_number('PROGRAMMINGS1.PRG_START','hh24');
    NUM_TOT & NUM_TEL are number variables,
    PROGRAMMINGS1.PRG_START is a Textfiel with a dateformat. There can only be an houre like 24:59:00 entered.
    So in this example I just want the houre and convert it to a number.
    The second:
    I want to make a date from a few numbers & then display it in a texfield.
    This is the code I already have:
    VAR_DATE := NUM_TEL || ':' || NUM_LENGTH || ':00';
    :PROGRAMMINGS.PRG_END := to_date(VAR_DATE,'hh24:mi:ss');
    Between the 2 lines of code i places a message(VAR_DATE) for testing.
    When the program display VAR_DATE then i can see the good date at the bottom of the screen.
    But when I place my variable in the textfield it looks like: 00:00:00. What am I doing wrong?
    Who can help me.
    With regards
    Stefanie

    Verdi wrote:
    Problem: During the conversion (both implicit and explicit conversion with a format mask) I lose the "00" hours and "00" minutes and receive something like this: "10-JAN-13 *12*.00.00.000000000 AM".I don't think you are necessarily losing any information whatsoever. It's probably more of a function of your NLS_TIMESTAMP_FORMAT and NLS_DATE_FORMAT. For example your NLS_DATE_FORMAT could be setup by default for a HH24 (24 hour time) which would report midnight as "00" hours. However, it looks like your NLS_TIMESTAMP_FORMAT is setup with a "HH" format with a meridian indicator which means 12 hours time.
    Your comparisons should be using date/timestamp data types anyways so as long as the input value is converted properly into a date type this shouldn't matter anyways.
    You can see what is actually stored by using the DUMP function:
    SQL> SELECT  DUMP(TO_TIMESTAMP(TO_CHAR(TRUNC(SYSDATE,'DD'),'MM/DD/YYYY HH:MI:SS AM'))) AS TSTAMP
      2  ,       DUMP(TRUNC(SYSDATE,'DD')) AS DT
      3  FROM DUAL
      4  /
    TSTAMP                                                                      DT
    Typ=187 Len=20: 218,7,1,13,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0                  Typ=13 Len=8: 218,7,1,13,0,0,0,0As you can see the TSTAMP and DT store nearly the same values (218,7,1,13), but the TSTAMP has more precision because of fractional seconds.
    HTH!
    Edited by: Centinul on Jan 13, 2010 7:23 AM

  • Calendar/Date set to local time MIDP/CLDC

    I've been playing around with the phone emulator and the Date and Calendar class. I noticed the time is always "UTC".
    My question is, will actual devices ALWAYS (e.g. the standard says) know their time zone? I've read the literature, and it seems to imply "NO", but I'm looking for a definitive answer.

    I also played aroung with Date, Calenadar und Timezone. I found out, that Date operates in GMT. Only Timezone that is requiered for mobiles to be implemented is GMT. Others may be present but do not have to, so as a serious developer, you need to work with GMT.
    I found out that there seems to be a problem with the correct dls time correction in GMT; it simply doesn't work right. I think this is because internally Java is working with UTC which does not work with dst and obvisouly they forgot to build in a correction that for.
    For your specific question i would say "no" too. Keep in mind, that even if J2ME is a standard the implementation on a special device is highly proprietary, so there is almost nothing you can get a definitive answer for... :-(

  • Conversion from data to duration

    Hi,
    I wish to convert a number, in seconds, to a duration.
    As follow: convert 289, which is in seconds, to a duration, which would be in minutes and seconds.
    289 seconds is 4 minutes 49 seconds, but how can I convert this in numbers?
    I also need to convert a full column of many numbers just as this one, how can I quickly convert many numbers like 289 (representing seconds) in a column in a duration?
    Thanks a lot in advance to all who can help,
    Paul

    Hi Contello,
    Thanks for your answer!
    It would be nice to be able to that automatically when having an entire column of data such as the one I told you about ... How could I do that?
    If I tell numbers 289 alone is a duration, it takes it as if it was 289 hours, not seconds!
    The only trick I found is to keep it as if it was hours, and then get a new cell next, in which the cell containing 289 is divided by 60 twice. Then it gives me 289 seconds converted in minutes and seconds, 4 min 49.
    Quite tricky isn't it?
    Is there a more "proper" way to do this?
    I really need to apply it to a big crunch of values ... So I need it to be automatic.
    Cheers!

  • Converting UTC dates to local time

    Hello all. I have some data I imported that has a date column containing dates spanning a number of years. The dates are in the UTC timezone.
    I need to display the dates in the local time zone that was in effect at the time. I've seen many fine examples of converting from one time zone to another. But I need it to be smarter than that. For example, date/times (this year) prior to 03/09/2008 2AM should display in EST (my zone in effect then), while date/times on/after then should display in EDT.
    Are there any Oracle built-in functions to do this, or will I need to gather the data of when daylight savings time begins/ends for the years I have dates and write my own function? I don't need help for the latter; I just don't want to reinvent the wheel. Also, I don't want to convert the data; I append to it regularly.
    Thanks for your help and consideration.

    Sergiusz, thanks again. When I added a very recent date, I saw the effect. But perhaps something is wrong with my local 10gR1 "play" database. It seems the DST start point is not correct. Should it not start showing -4 offset at row# 4? I didn't see a change until I added the last date. But I believe DST began on 3/9/2008 at 2am local, which is 7am UTC.
    ~Pete
    SQL> DROP   TABLE imported_events;
    Table dropped.
    SQL> CREATE TABLE imported_events (event_date TIMESTAMP(0) WITH TIME ZONE);
    Table created.
    SQL> BEGIN
      2  INSERT INTO  imported_events VALUES ( '10-JAN-08 2:00:00 PM UTC');
      3  INSERT INTO  imported_events VALUES ( '08-MAR-08 2:00:00 PM UTC');
      4  INSERT INTO  imported_events VALUES ( '09-MAR-08 6:59:00 AM UTC');
      5  INSERT INTO  imported_events VALUES ( '09-MAR-08 7:01:00 AM UTC');
      6  INSERT INTO  imported_events VALUES ( '09-MAR-08 2:00:00 PM UTC');
      7  INSERT INTO  imported_events VALUES ( '10-MAR-08 2:00:00 PM UTC');
      8  INSERT INTO  imported_events VALUES ( '09-JUN-08 2:00:00 PM UTC');
      9  COMMIT;
    10  END;
    11  /
    PL/SQL procedure successfully completed.
    SQL> COLUMN ROWNUM         FORMAT 99
    SQL> COLUMN event_date_utc FORMAT A25
    SQL> COLUMN offset_local   FORMAT 99
    SQL> COLUMN offset_eastern FORMAT 99
    SQL> SELECT ROWNUM
      2        ,event_date event_date_utc
      3        ,TO_CHAR(CAST((event_date AT LOCAL) AS DATE),'YYYY-MM-DD HH24:MI:SS') date_local
      4        ,(CAST((event_date AT LOCAL) AS DATE) - CAST(event_date AS DATE))*24 offset_local
      5        ,TO_CHAR(CAST((event_date AT TIME ZONE 'US/Eastern') AS DATE),'YYYY-MM-DD HH24:MI:SS') date_eastern
      6        ,(CAST((event_date AT TIME ZONE 'US/Eastern') AS DATE) - CAST(event_date AS DATE))*24 offset_eastern
      7    FROM imported_events
      8   ORDER BY 1;
    ROWNUM EVENT_DATE_UTC            DATE_LOCAL          OFFSET_LOCAL DATE_EASTERN        OFFSET_EASTERN
         1 10-JAN-08 02.00.00 PM UTC 2008-01-10 10:00:00           -4 2008-01-10 09:00:00             -5
         2 08-MAR-08 02.00.00 PM UTC 2008-03-08 10:00:00           -4 2008-03-08 09:00:00             -5
         3 09-MAR-08 06.59.00 AM UTC 2008-03-09 02:59:00           -4 2008-03-09 01:59:00             -5
         4 09-MAR-08 07.01.00 AM UTC 2008-03-09 03:01:00           -4 2008-03-09 02:01:00             -5
         5 09-MAR-08 02.00.00 PM UTC 2008-03-09 10:00:00           -4 2008-03-09 09:00:00             -5
         6 10-MAR-08 02.00.00 PM UTC 2008-03-10 10:00:00           -4 2008-03-10 09:00:00             -5
         7 09-JUN-08 02.00.00 PM UTC 2008-06-09 10:00:00           -4 2008-06-09 10:00:00             -4
    7 rows selected.
    SQL>

  • Valid From Date in CT04

    Hi,
    We are on ECC 6.0. When I try to create a Characteristics in CT04, the Valid From date defaults to the System Date. If I change this date to any other date in the past, it saves the system date only.
    How do I make the Valid From date to something else?
    Regards,

    Dear Shameek,
    why do you want to create the characteristics for a past date?
    This is possible by creating a change number in CC01 with the valid from date as say 01.07.2011 and include the check box for
    characteristics in the object type(active) and use the change number in CT04 and check the results.
    But the drawback in this procedure is the system always expects a change number during the next change for that
    characteristics.
    Check and revert back.
    Regards
    Mangalraj.S

  • Is PGI date beased on system date or user profile time zone date?

    Hi All,
    When doing PGI what date system will take as Actual good issue date ? whether the System Date or User local Time zone date which maintained in User profile. If you have any idea on this please share.
    Regards,
    Lakshmikanth

    Hi,
    You need to check with the basis team for settings this to your local time.
    You can also check the field Personal time zone of the user in t.code SU01. I am not sure this will update the timings in the database when the user performs some action.
    Regards

  • Time Conversion from Local to UTC Help! - Daylight Savings Problem?

    Hi,
    I am trying to use the generic conversion of local time to UTC time.  I thought I had everything working since I use the "Get Date/Time in Seconds" and then convert to "Seconds to Date/Time" witht the "to UTC" flag set true.  Then I convert back to a timestamp.
    I thought I had everything working until I hit Daylight Savings for the Pacific Standard Time.  Now the Labview is off by 1 hour!
    Is there an update to the Subvi's that do this?  Is this a known error?  Please help.   Thank you!
    Attachments:
    test25_LocalToUTC_Time.vi ‏8 KB

    Here is the path you are doing that is causing the logic to fall apart for you.
    1.  You are getting the current time.  In your images, it is 12:41 pm PDT which is 7:41 pm GMT
    2.  You are asking for the date/time record (that cluster that breaks out everything) but are saying it is UTC, so you get a date/time record that 19:41 UTC (7:41 pm).  And the DST flag is 0.  (Because UTC doesn't observe daylight savings time.)
    3.  Now  you are taking that date/time record and converting back to an actual date/time.  You don't wire up the UTC flag so it defaults to false.  Thus the date/time record is interpreted as local.  That DST flag is still 0 in your cluster.  So you are actually converting the time to 7:41 pm PST, which is actually 8:41 PDT.  (+1 hour for spring forward based on the month/date info.)
    4.  You are displaying that time stamp in the indicator labelled "Current Date/Time (UTC)", but it is not truly UTC, it is actually the conversion of a local time from PST to PDT, and it is not even the current local time.  It is actually a "local" time 8 hours into the future.  If you put the carat into that indicator's display format, you'll see that the UTC time is in the future as well.  You call it UTC, but you are displaying a future local time.
    The inconsistent conversions from local to UTC, and not accounting for the change of the DST flag from daylight time to UTC are what is confusing you.  You kind of get lucky during standard time because the DST flag is 0 for both local standard time and UTC.  But the conversions are still wrong, but it is a case of two wrongs are making it look right.  Even in standard time your input timestamp and your output timestamp indicator don't match which you would see if you used an Equals? function on them.

  • Date/time conversion from UTC to CET

    Hello,
    Jjust a little question to our SAP BI community!
    Is there a BI function/ggod way that converts a (datetime) string DDMMYYYYHH:MM:SS  in UTC time zone into a string DDMMYYYYHH:MM:SS in  CET timezone ?
    We receive this string in input in a flat file and need it to convert from UTC to CET.
    Or do you know any way to convert a date/time from IUTC to CET, eveen using an ABAP function?
    Thanks a lot,
    Matthieu

    Hi,
    Check this thread for time conversion from UTC to Local time
    [ABAP statement for converting UTC date/ time to local date/time],
    Regards,
    Daya Sagar

  • Recovering data from Time Capsule after conversion from Snow Leopard to Lion

    Had a problem with my iMac, which was running Snow Leopard O/S.  Data was backed up on Time Capsule using Time Machine, although recent back-ups had failed (but earlier back-ups had been OK).  Apple support determined that I needed to re-install the O/S and they walked me through it.  After blowing away all data (believing that once O/S reinstalled, could recover from Time Capsule), the reinstall failed.  Took to Apple store, where they installed Lion at my request.  Then tried to recover from Time Capsule, but couldn't do so.  Sparse file doesn't work (it shows 10GB, which is wrong as it had several hundred GB's before due to lots of photos).  Apple Support couldn't solve issue, believes it was corrupted with the last backup.  Ultimately recommended that I have professional data recovery service recover data from the iMac hard-drive (as opposed to Time Capsule).  Spoke to recovery service recommended by Apple, and it is very expensive (also, given the O/S reinstall, anything they recover will have new file names and no directory structure).  They also said getting data off the Time Capsule is even more difficult and expensive to recover.  I'm not a happy camper. 
    I would welcome any thoughts on what to do.  FWIW, I live in South Florida and there appear to be lots of data recovery companies locally, but Apple support had said that they have only a few authorized vendors that can do it without voiding warranty, so I'm reluctant to even call them.  Thanks.  Steve

    Your backups may be corrupted.
    Try to repair them, via Disk Utility (in your Applications/Utilities folder).
    Mount the sparse bundle by opening the TC in the Finder and double-clicking on the sparse bundle. Drag the sparse bundle into Disk Utility's sidebar, and do a +*Repair Disk*+ (not permissions) on it. If it finds errors it can't fix, run it again (and again), until it either fixes them all, or can't fix any more.

  • Conversion between local time and UTC: Anomaly at Daylight saving time edge

    Hi all,
    I want to convert back and forth between local time including all peculiarities like DST etc. This is the core of my code:
        Date d=new Date(toEpoch());
        Calendar cal=Calendar.getInstance(tz);
        cal.setTime(d);
        int offs=(cal.get( Calendar.ZONE_OFFSET )+cal.get( Calendar.DST_OFFSET ));
        System.out.println("zone_offset: "+cal.get( Calendar.ZONE_OFFSET )+", dst_offset: "+cal.get( Calendar.DST_OFFSET )+", offset: "+offs);
        Calendar cal2=Calendar.getInstance(TimeZone.getTimeZone("Etc/UTC"));
        System.out.println(cal2.getTimeZone().getID());
        cal2.setTime(d);
        cal2.add(Calendar.MILLISECOND,-offs);
        d=cal2.getTime();Looks (and, actually, is) rather complicated. I take two different calendar objects to be absolutely sure that no accidental DST conversion hits me on the UTC side.
    The general case works as expected:
    Date (fourteen digits, 'x'=Exit): 20050909190000
    Entered date: Fr, 9.9.2005, 19:00
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Etc/UTC
    Date in UTC:  Fr, 9.9.2005, 17:00I live in timezone Europe/Berlin, so during DST we have GMT+2. Let's see what's happening on christmas (non-DST):
    Date (fourteen digits, 'x'=Exit): 20051224180000
    Entered date: Sa, 24.12.2005, 18:00
    zone_offset: 3600000, dst_offset: 0, offset: 3600000
    Etc/UTC
    Date in UTC:  Sa, 24.12.2005, 17:00As expected!
    Now, we enter the dark zone of DST: Each year DST is turned on and off and it seems as if this leads to problems in both cases. Let's start with the next event of this case: At Oct., 30th, 2005, DST is turned off between 2:00 and 3:00 at night. So, we have once 2:30 with DST and (one hour later) 2:30 again without DST. Java, however, garbles things completely (I'm leaving the unneeded lines of my debug output out now):
    Entered date: So, 30.10.2005, 01:59
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  Sa, 29.10.2005, 23:59
    Entered date: So, 30.10.2005, 02:00
    zone_offset: 3600000, dst_offset: 0, offset: 3600000
    Date in UTC:  So, 30.10.2005, 02:00
    Entered date: So, 30.10.2005, 02:30
    zone_offset: 3600000, dst_offset: 0, offset: 3600000
    Date in UTC:  So, 30.10.2005, 02:30
    Entered date: So, 30.10.2005, 02:59
    zone_offset: 3600000, dst_offset: 0, offset: 3600000
    Date in UTC:  So, 30.10.2005, 02:59
    Entered date: So, 30.10.2005, 03:00
    zone_offset: 3600000, dst_offset: 0, offset: 3600000
    Date in UTC:  So, 30.10.2005, 02:00So, directly before the DST change, offset is computed correctly. From 3:00 onward, also. But in between, Calendar does neither take an offset of two hours (what would be somehow correct) nor one hour (also somehow correct). Even though it predicts to take the one-hour zone offset into consideration, "GMT" time is actually the same as local time.
    Things become even wireder at the other edge of the DST time range: This year, DST began on March, 27th, 2005: Let's see what is happening:
    Entered date: So, 27.3.2005, 01:59
    zone_offset: 3600000, dst_offset: 0, offset: 3600000
    Date in UTC:  So, 27.3.2005, 00:59
    Entered date: So, 27.3.2005, 02:00
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  So, 27.3.2005, 00:00
    Entered date: So, 27.3.2005, 02:30
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  So, 27.3.2005, 00:30
    Entered date: So, 27.3.2005, 02:59
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  So, 27.3.2005, 00:59
    Entered date: So, 27.3.2005, 03:00
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  So, 27.3.2005, 00:00
    Entered date: So, 27.3.2005, 04:59
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  So, 27.3.2005, 01:59
    Entered date: So, 27.3.2005, 05:00
    zone_offset: 3600000, dst_offset: 3600000, offset: 7200000
    Date in UTC:  So, 27.3.2005, 03:00While at 1:59, everything is ok, 2:00 is handled as within DST. That's ok, as the hour between 2:00 and 3:00 did not exist in that night in our local time zone, but at 3:00 the system totally screws up things as it suddenly subtracts three hours (while pretending to use two hours). This goes on until 5:00 in the morning when time is shown correctly again.
    Can anyone help me? What am I doing wrong? How do I actually convert correctly between a DST-aware local time zone and GMT/UTC?
    Best regards,
    Dirk

    Well, I would not say I did "just about everything" wrong. Actually, Calendar is not GMT-only as it has time zone information and converts its internal time according to that information if I use the getTime() function (what I do).
    In my applications, I handle dates in my own data structures. My EDate object (which is part of the QJCC library hosted on SourceForge) stores years, months, days, minutes, hours, and seconds seperately. Using this class, I managed to get an actually working time zone conversion this way:
      public void toUTC(TimeZone tz) {
        Calendar cal=Calendar.getInstance(tz);
        cal.clear();
        cal.set(year,month-1,day,hour,minute,second);
        int offs=(cal.get( Calendar.ZONE_OFFSET )+cal.get( Calendar.DST_OFFSET ));
        //System.out.println("zone offset: "+cal.get( Calendar.ZONE_OFFSET )+", DST offset: "+cal.get( Calendar.DST_OFFSET ));
        second-=(offs/1000);
        normalize();
    normalize() does something similar to the lenient stuff in Calendar.
    I will now write the method for the other direction. The most interesting item will be the answer to the question:
    "Tell me the correct DST_OFFSET in TimeZone X when I have the actual point of time given in UTC."
    Perhaps someone can give me a hint?!?

Maybe you are looking for