Convert date/time to GMT format

Hi,
I want to convert my current system date to GMT format. the class java.util.Time/Calender have methods which help u to convert from GMT to local time.
is there a method to convert from current System Date to GMT.
tx in advance

i found the answer to my earlier question from the postings. Now i need help with the format og the Date in GMT.
i used the following code to get the GMT based on the system time
Calendar here = Calendar.getInstance();
int gmtoffset = here.get(Calendar.DST_OFFSET)
+ here.get(Calendar.ZONE_OFFSET);
//to convert to GMT time
Date GMTDate = new Date(System.currentTimeMillis() - gmtoffset);
the result of exceuting the following code is
GMT Date is Mon Aug 20 18:39:19 EDT 2001
but i need the GMT time in this format
20010820-18:39:40
tx
Namrata

Similar Messages

  • Internationalization  issue : convert date/time to GMT/UTC

    We have our webservices running in websphere /oracle.There is this requirement to internationalize the application ...like
    a) language .....
    d)Internatiolization of time :
    For this requirment I am planning to do the following.Service request with date will be converted to GMT before it is stored in database and the response back will be converted from GMT back to the time zone of the requester and have the application server/database server configured to UTC time.Is this a good strategy or is there a better one.
    Thanks
    m

    Manjit wrote:
    Sabre,to confirm again...you are suggesting that there is even no need to change the oracle Date field from Date type to Timestamp.The only thing I really have to do is for display purpose convert/format the response date to the zone the request is coming from.Please let me know if I missed anything.The above statement is indefinite.
    Are you starting with a java.util.Date or perhaps a java.sql.Timestamp?
    Then you do NOT convert them. You display them. You use SimpleDateFormat for that. You do not concern yourself at all with timezones exception in terms of creating a SimpleDateFormat. And that is ONLY an issue if you are creating the string (display value) on a server. If you are doing that you will need the client to provide you with a timezone. There is no magic way to get that from the client. If a client app is doing the display the the client is running in a client VM and that VM will already have a display format that might be suitable.
    Conversely if you are receiving a timestamp value as a text value (say read it from a file) then you must convert that into a java.util.Date. You do that via SimpleDateFormat. The specifics of how you do that depends on the form of the text value.

  • Convert date time local Timezone  to GMT

    I need to get GMT time...
    How to convert local time to GMT ?
         public static long getGMTNow()
             Calendar local = new GregorianCalendar();
             local.set(Calendar.HOUR_OF_DAY, 0);              
             local.set(Calendar.MINUTE, 0);
             local.set(Calendar.SECOND, 0);
             System.out.println(local.getTime());
             System.out.println(local.getTimeInMillis());
             Calendar gmtC = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
             gmtC.setTimeInMillis(local.getTimeInMillis());
             System.out.println(gmtC.getTime());
             return gmtC.getTimeInMillis();
         }Result :
    Thu Feb 12 00:00:00 EST 2009
    1234414800034
    Thu Feb 12 00:00:00 EST 2009
    1234414800034

    Calendar gpsTime = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
             gpsTime.set(Calendar.HOUR_OF_DAY, 10);              
             gpsTime.set(Calendar.MINUTE, 0);
             gpsTime.set(Calendar.SECOND, 0);
             System.out.println("gpsTime: "+gpsTime.getTime());
             Calendar realtime= new GregorianCalendar();
             realtime.set(Calendar.HOUR_OF_DAY, 5);              
             realtime.set(Calendar.MINUTE, 0);
             realtime.set(Calendar.SECOND, 0);
             System.out.println("realtime: "+realtime.getTime());
             System.out.println("COMPARETO : "+ realtime.compareTo(gpsTime));
             long timediff = realtime.getTimeInMillis() - gpsTime.getTimeInMillis();
             System.out.println(timediff/1000 + " sec");RESULT :
    gpsTime: Mon Feb 16 05:00:00 EST 2009
    realtime: Mon Feb 16 05:00:00 EST 2009
    COMPARETO : 1
    0 secOk, I done my homework. getTime() will allways return local time so I need to set the GPS time to a GMT Calendar to get the right result.
    Funny thing, look at the compareTo result....

  • How convert date/time from xml in xdp(Designer)?

    Hi, i want to convert date/time format from xml in Designer, date/time value in xml is NOT in common format YYYY-MM-DD (if is in a common format i can do this with pattern)
    I have a "DateTime" Field in Xdp can get from Xml date and time:
    In XML <DateTime>DD-MM-YYYY</DateTime> i want to convert in XDP in DateTime Field in "DD-April-YYYY"
    Can i do this?

    You can do this way..
    Bind the date field to your XML tag.
    Set the display pattern for the date field.
    In the initialize event of the date field place the following code.
    Set JavaScript as language.
    var dtStr = this.rawValue;
    var pos1=dtStr.indexOf("-");
    var pos2=dtStr.indexOf("-",pos1+1);
    var strMonth=dtStr.substring(0,pos1);
    var strDay=dtStr.substring(pos1+1,pos2);
    var strYear=dtStr.substring(pos2+1);
    //Assign the formatted value to the Date field.
    this.rawValue = strYear + "-" + strMonth + "-" + strDay;
    Thanks
    Srini

  • Convert local time to GMT

    Hi everybody,
    i receive a lot of operation date from many worldwide ports like these:
    SINGAPORE 23/FEB/2011 13:50 (local time)
    GHENT(NL) 23/FEB/2011 12:00 (local time)
    i'm required to convert these information to GMT date.
    I've found NEW_TIME function but it seems inadequate:
    1) the function does not consider daylight saving periods; i mean when tmz1 switches from daylight savings on to daylight savings off and tmz2 does not, the function does not change the time difference (at least it's the result of my test unless all valid timezones switch at the same time)
    2) valid parameters are 18 therefore they don't cover all the possible combinations
    Could you please help to cope the matter ?
    Many thanks in advance
    Stefano

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by David Hsiung ([email protected]):
    How can i convert local time to GMT time in
    the Form?<HR></BLOCKQUOTE>
    David,
    there is a date function caled NEW_TIME that should work. For ex:
    select to_char(new_time (sysdate, 'EST','GMT'), 'HH:MI:SS')
    from dual;
    05:31:00

  • FUNCTION MODULE TO CONVERT DATE / TIME INTO WORDS.

    HI EXPERTS,
         FUNCTION MODULE TO CONVERT DATE / TIME INTO WORDS.
    PLS DO HELP.....

    Hiii gita
    we have another FM SPELL_AMOUNT
    regards
    Jaipal

  • Time in GMT Format

    Hi
    I want to display current time in GMT format.
    Can anyone tell me the query to display current time in GMT format.
    -haifriends

    Then, like i said, you'd want to use SYS_EXTRACT_UTC
    SCOTT @ nx102 JCAVE9420> select systimestamp from dual;
    SYSTIMESTAMP
    08-OCT-06 01.42.54.673000 AM -04:00
    Elapsed: 00:00:00.09
    SCOTT @ nx102 JCAVE9420> select sys_extract_utc( systimestamp ) from dual;
    SYS_EXTRACT_UTC(SYSTIMESTAMP)
    08-OCT-06 05.43.06.626000 AM
    Elapsed: 00:00:00.01Justin

  • Email Templates and Date and Time in GMT Format

    How do I send the date and time captured on the service form to the customer and not how it renders in GMT when sent in the email template
    Solution: Copy the service form field into a hidden field.  Reference the hidden field in the email template and it appears in the email template as entered on the form.

    But what about a system generated date/time like trying to notify a task assignee of the due date/time of their task?

  • How to convert date-time according to the Time Zone the client

    Urgent! Help wanted!
    I extract a date-time field (which is GMT time) from the central database but I need to convert it accordding to the TimeZone of the user and also the so-called winter time and summer time in the local. Any one has any good solution?
    Thanks.

    Use a Calendar, Timezone and Locale objects like this,
    TimeZone tz = TimeZone.getTimeZone("Germany/Berlin");
    Calendar cal = Calendar.getInstance(tz, Locale.GERMAN);
    long date = 0; // assign your central database value to this variable
    cal.setTime(new Date(date));
    Now you can use the Calendar object 'cal' to retrieve the time according to the set locale and timezone.
    These objects provide tonnes of features for finding out timezones and day light savings times. So check out the APIs as well.
    I hope this helps you out.

  • Convert date/time to a value in second

    Hello,
    I want to convert a basic date time variable into a numeric one corresponding to the time (in second) passed since January,1,1970 in order to put it in a SQL statment as a criteria.
    Is someone able to help me ?
    Regards

    If you have an java.util.Date object you can call getTime() method on it. It will return milliseconds. Just divide it on 1000. Here is example code:
    java.util.Date date = new java.util.GregorianCalendar(2001, 7, 6).getTime();
    long seconds = date.getTime() / 1000;
    //Your code
    Best regards, Alex.

  • How to convert Date in varchar(50) format MM/DD/YYYY HH:MM into YYYY-MM-DD format using MS SQLServer 2008 R2 ?

    Hi,
    I am getting the error "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value."
    when converting date in format Date in varchar(50) format MM/DD/YYYY HH:MM into YYYY-MM-DD format using MS SQLServer 2008 R2.
    Please note that the date in column is Date(varchar(50), null).
    I used the following syntax:
    SELECT  CONVERT(VARCHAR(10), Date, 102) AS Day
    FROM   dbo.[RCap_2G MM/Operator]
    WHERE  (CONVERT(VARCHAR(10), Date, 102) > { fn NOW() } - 1)

    As noted above, either use ISDATE or TRY_CONVERT with the correct conversion style number:
    -- SQL Server 2012 code
    DECLARE @Date varchar(50) = '10/23/2006 10:20';
    SELECT TRY_CONVERT(DATE, @Date, 101) AS Day
    -- 2006-10-23
    Datetime conversion blog:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Convert date/time to Unix epoch

    I have thousands of date time stamps I would like to convert to Unix epoch ten-digit strings. That is, take some thing like:
    Dec 9, 2005 10:24 AM
    and convert to
    1234567890 (only in the correct unix epoch time)
    What formula can I use? I've found that this "=DATE(1970,1,1)+P2/86400" can convert a 10 string epoch time down to just a date correctly, but without time. But I need to go in the opposite direction, with the time included.
    Using Numbers 09 ver 2.0.5 (368)

    CP,
    An up-to-date Unix Time would be provided by:
    =DUR2SECONDS((NOW()-"1/1/1970"))
    A somewhat more robust form would be:
    =DUR2SECONDS(NOW()-DATE(1970,1,1))
    If the time to be converted is in Cell P2, the expression would be:
    =DUR2SECONDS(P2-DATE(1970,1,1))
    Jerry

  • Convert date/time to HEX command and write to a bin file

    Hello,
    I have to do the following thing. I have the date/time string, let's say 08:45:23, 12.08.09, where the hour, the minutes, the seconds, the day, the month and the year represent hex number or in other words I have the following command:
    Byte 0 - Byte 5
    0x08; 0x45; 0x23; 0x12; 0x08; 0x09;
    Now I want to write this command in a binary file in order to send thefile later throught serial RS232 connection.
    Now, I am not sure whether I write the command in the binary file in the correct format. What I simply do is to write it as a string
    ("084523120809"). Is this the correct way. I guess no, because when transmitted it does not work as expected.
    How can I write this string as a HEX command in the binary file?
    Thanks for the replies in advance
    IG
    Message Edited by igurov on 08-12-2009 01:51 AM
    Attachments:
    1(2).JPG ‏39 KB

    Do you know the difference between decimal and hex values? It's not the same, that the whole point, and it's why it doesn't make sense. Decimal 32 is not the same as hex 32. These are two different values, even though they both have the digits "3" and "2". The hex value will be the same as the decimal value up to the value of 9. In your example the hour is 8. In decimal this is 8, in hex this is 8. The minutes is 45. That's decimal. In hex, this is 2D, not 45, as you claim in your example. Hex 45 is a completely different number (and a completely different "pattern").
    Attachments:
    time hex.vi ‏12 KB

  • How do get current date/time in GMT?

    Is there any way to get the current date and time in GMT (while my current locale is not GMT)?
    In Java I can do this:
    long currenttime = System.currentTimeMillis();
    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
    df.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    java.util.Date date = new java.util.Date();
    date.setTime(currenttime);But, there seems to be no way to do the equivalent in BPEL in SOA Suite.
    I did some research and I think I could appy the XPath 2.0 function adjust-dateTime-to-timezone() to the current time, but that function is not available.
    Using SOA SUite 11.1.13.0.
    THanks.

    have you tried changing the stylesheet version in the xsl to 2.0 and then try the function again ?
    by changing this version it was possible to use newer functions, which weren't available in the designer

  • Convert Data time stamp to Local Time

    Hello,
    I want to convert this input to local time EST.
    Input:12/8/2006 10:23:00.000000000 PM -06:00
    o/p: EST.Local Time

    Is the input a string? A timestamp? If so, which flavor of timestamp? Something else?
    Normally, you'd want to use a TIMESTAMP WITH LOCAL TIME ZONE data type for this sort of requirement, since it automatically converts data to the client's time zone. Assuming the input is a string and that the client's time zone is set to EST
      1  select cast(to_timestamp_tz( '12/8/2006 10:23:00.000000000 -06:00',
      2                               'MM/DD/YYYY HH24:MI:SS.FF TZH:TZM' )
      3                AS TIMESTAMP WITH LOCAL TIME ZONE)
      4*   from dual
    SCOTT @ nx102 JCAVE9420> /
    CAST(TO_TIMESTAMP_TZ('12/8/200610:23:00.000000000-06:00','MM/DD/YYYYHH24:MI
    08-DEC-06 11.23.00.000000 AM
    Elapsed: 00:00:00.01
    SCOTT @ nx102 JCAVE9420> Justin

Maybe you are looking for