UTC Dates

Hello.
I already search by this topic in the forum searh engine , and i have found a lot of issues related with this topic but none of these have clarified me.
I read that when you create a Date object like this away Date d = new Date(); , that will contain the date in UTC(number of miliseconds since 01/01/1970), but when i simple
do System.out.println(d) this will print the date in my local machine timezone.
How can I hava a Date object with the UTC time ?
Thanks

PedroCosta wrote:
Hello.
I already search by this topic in the forum searh engine , and i have found a lot of issues related with this topic but none of these have clarified me.
I read that when you create a Date object like this away Date d = new Date(); , that will contain the date in UTC(number of miliseconds since 01/01/1970), but when i simple
do System.out.println(d) this will print the date in my local machine timezone.
How can I hava a Date object with the UTC time ?
As you have stated, Date objects only have a UTC time! Do you mean that you want a String representation in UTC time zone? If so then use SimpleDateFormat and set the time zone to UTC.

Similar Messages

  • Convert String to java UTC date then to sql date

    Hi,
    I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
    This is what I did:
    String dateAsString = "10/01/2007";
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    formatter.setLenient(false);
    java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
    dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
    Now I need to store this date and time to MS SQL database.
    I used the following code:
    java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
    But this code give only the date, not time 2007-09-30
    Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
    Thanks,
    semaj

    semaj07 wrote:
    Hi,
    I am trying to convert string (MM/dd/yyyy format) to UTC date time and store in the database.
    This is what I did:
    String dateAsString = "10/01/2007";
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
    formatter.setLenient(false);
    java.util.date dateValue = formatter.parse(dateAsString, new ParsePosition(0));
    dateValue will be Sun Sep 30 20:00:00 EDT 2007 in UTC.
    Now I need to store this date and time to MS SQL database.
    I used the following code:
    java.sql.Date sqlDateValue = new java.sql.Date(parsedToDate.getTime());
    But this code give only the date, not time 2007-09-30
    Can anybody tell me how I can change this java date to sql date (or datetime?) so that I can get both date and time.
    Thanks,
    semajTake a look at java.sql.Timestamp:
    http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html
    Edited by: hungyee98 on Oct 17, 2007 8:57 AM

  • PowerBI regional/localisation settings (date time format/timezone) - PowerPivot dax NOW() returning UTC date

    Can the regional settings be changed for PowerBI or are we stuck with UTC? Tried googling but the only hits for 'regional powerbi' relate to the portal being available in that region, not any kind of localisation configuration
    I have a workbook that is set to auto refresh. I've added a 'last refreshed' label to the front page, but when refreshed on PowerBI it shows the time in UTC (10.5 hrs off from where I am).
    I'm not a sharepoint person so will need steps and diagrams if it's a sharepoint config setting :)
    Jakub @ Adelaide, Australia Blog

    Hi Ed,
    I have a date dimension and I add a computed column to it. It's called RefreshDate. The code for the computed column is =NOW()
    I then use this column to show to the user when the model was last refreshed.
    Hi Greg, not really interested in workarounds at this time (i have another thread going for that & my data source is web apis, not a relational db with datetime functions) -
    this is more of a question of "is it possible to choose which timezone is used by the powerbi vertipaq engine for scheduled refreshes? yes/no"
    We are working in a single time zone, but the PowerBI vertipaq engine looks like it's lives in london.
    It shows the correct current time on the local user's PC when I (or a user) refreshes this model locally. It shows the UTC date (my time zone - 10.5 hrs) when the report is refreshed by powerbi.
    I have a workaround going in my report currently using powerquery to get the utc date and manually add 10.5 hrs + add a label to my report that states this is a fixed 10.5hr. This is a hack because we're in a daylight savings zone, so in a few months
    the tz will revert to +9.5hrs and i'll need to manually fix this again unless i'm able to set powerbi to use my time zone.
    The sharepoint guys here have changed every setting they know about in sharepoint online/o365 in regards to time zones and localisation. The date format and dates shown are correct for the 'web pages' part of powerbi (the refresh history, the formatting
    of the dates on the powerview reports etc), but the time zone used when powerbi executes the NOW() dax command appears to be set to UTC.
    Thanks
    Jakub @ Adelaide, Australia Blog

  • UTC Date/Time conversion

    Is there a documented formula for converting UTC date/time stamps in CallDetailRecords (e.g., 1074902387) to a recognizable time/date?

    In Call Manager, the CDR exports are in EPOCH time. Here is the  formula to convert epoch time in a Call Manager CDR to a standard format  in excel. After using the formula, you will need to format the cell for  date and time.
    =(((E2-(6*3600))/86400)+25569)
    E2 = cell reference
    6 = Timezone Offset (this is Central Standard time)
    3600 = Number of seconds in an hour
    86400 = Number of seconds in a day
    25569 = Excel hack because excel counts epoch from 1/1/1904 and most others start at 1/1/1970.
    Found this formula on the following webpage:
    http://ciscovoiceguru.com/473/convert-epoch-utc-time-in-excel/

  • Power Query Language Functions to Convert a UTC Date/Time to MST

    I need to convert an implicit UTC date/time value to a MST date/time value.  I thought that I could achieve this by converting to an ISO 8601 compliant text representation of the MST date/time value (see below) and then back to a date/time value, but
    it's not working ...
    DateTime.FromText( DateTime.ToText( [MIN_REVSN_RLSE_DTTM] ,"yyyy-MM-ddThh:mm:ss-07")) 
    Is this a bug?  Or, is there a better way to do this?

    That's a fixed duration. Why not just [MIN_REVSN_RLSE_DTTM] + #duration(0, -7, 0, 0)?
    EDIT: For what it's worth, I don't think PQ ever does anything with DST anyway. This has both good points and bad points.

  • ABAP statement for converting UTC date/ time to local date/time

    Hi
    Is there any abap statement or any function module in BW which converts UTC date and UTC
    time into local date and local time according to specific country.
    Regards,
    Kate

    Hi,
    and to convert the country to a timezone first use: TZ_LOCATION_TIMEZONE
    /manfred

  • Getting UTC date from NSDate

    I am using following function to convert NSDate in "UTC" date.
    -(NSString *)getUTCFormateDate:(NSDate *)localDate
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
    [dateFormatter setTimeZone:timeZone];
    [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString *dateString = [dateFormatter stringFromDate:localDate];
    return dateString;
    I am getting result correct for some dates and I am not getting it correct for some of date.it converts time perfectly , but for some date it converts year to the next year.
    following are some observation.
    firstDate = 2008-12-27 17:17:58 +0530.
    firstUtcDate = 2008-12-27 11:47:58.
    secondDate = 2008-12-29 16:30:00 +0530.
    secondUtcDate = 2009-12-29 11:00:00 //the year has been changed.
    thirdDate = 2008-12-29 17:00:00 +0530
    thirdUtcDate = 2009-12-29 11:30:00 //again the year has been changed.
    Can anyone tell me what is problem with function.
    Thaks
    Message was edited by: xmax
    Message was edited by: xmax

    xmax wrote:
    I am using following function to convert NSDate in "UTC" date.
    -(NSString *)getUTCFormateDate:(NSDate *)localDate
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
    [dateFormatter setTimeZone:timeZone];
    [dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSString *dateString = [dateFormatter stringFromDate:localDate];
    return dateString;
    Can anyone tell me what is problem with function.
    Try changing the year formatting arguments to "yyyy". "YYYY" means something else besides the year: Year (of "Week of Year"), used in ISO year-week calendar. May differ from calendar year.
    See the Unicode docs for an explanation.
    charlie

  • UTC Date Format

    Hi,
    I am facing the following problem.
    Say If I use the following select command
    select upd_date
    from table
    where id=123
    I get as result => 22.08.07
    I know that this result is in UTC Format.
    I would like to get the localformat with hour min and sec.
    Which function do I have to use for it, to get the local time?
    select ?func?( upd_date )
    from table
    where id=123
    Google leads me to SYS_EXTRACT_UTC.
    1st of all I can't use it with my column upd_date.
    But I think this function is if the stored value would be in localtime
    and I would like to get the UTC date time of it. LOCAL => UTC.
    I want the opposite version. UTC => LOCAL
    thanks for any hint
    aykut

    unfortunately returns your code the stored date value as is and not the converted localdate.
    say, user sets a meeting date via GUI.
    user sees the local date, e.g. 31.11.2007 14:01:23
    User lives in an area with the timezone UTC +1 e.g. in London,
    (the database is set as UTC +1 as timezone)
    that means the value is stored as 31.11.2007 15:01:23
    The conversion depends on summer and winter time.
    So if I submit a SELECT for a stored value: "31.11.2007 14:01:23"
    I expect to get "31.11.2007 15:01:23"
    With your SQL I get the same value as is in the database.

  • UTC Date Time and Normal Date Time

    Hi All,
    1. How UTC date time and Normal date time differs in siebel.
    2. If legacy data needed to be loaded into siebel, in siebel few fields are date time and UTC date time fields. what would happen if we load both normal date time and UTC date time without considering them techinically?
    3. UTC date time holds any specific format in physical database? If we want to load legacy data to UTC date time format what is the query to manipulate it?
    Thankyou
    Sean

    Sean,
    Please check document below, I believe it has most of the answers to the questions you have:
    http://download.oracle.com/docs/cd/E14004_01/books/GlobDep/GlobDepUTC.html
    Hope it helps,
    Wilson

  • UTC date conversion:

    Is there a function to convert UTC time to a normal date format?
    I have the stored seconds since the 'epoch' -1970 and would like to convert that over to a normal date in a report.

    I wrote a code tip that has been published in a couple of journals and webboards. Here's a link to something may help you exactly:
    http://www.revealnet.com/Pipelines/plsql/archives.htm#code29
    Giovanni Jaramillo
    null

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

  • 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

  • Having strange issues with kbmap and utc/localtime

    Hello,
    I've been using Archlinux for a month or so, never had any problems until now.
    1. Setting the keymap doesn't stick. At first I had the German keymap selected in System-Preferences-Keyboard, and at reboot it would switch back to the standard US layout. Yesterday I deleted the current layout and again added German as the default.. And at bootup today I had a russian layout .
    2. I haven't been able to get the UTC function properly working.. The hwclock was set in UTC (date -u showed the correct time), UTC was set in the rc.conf, but the Gnome clock always showed the wrong time. (Now localtime is set in rc.conf)
    2a. Related to that, I installed openntpd and added it as a startup daemon.. System-Administration-Time and Date still gives me an error message "NTP support is not installed" when I set the configuration to "Keep synchronized with internet servers".
    Here's my rc.conf
    # /etc/rc.conf - Main Configuration for Arch Linux
    # LOCALIZATION
    # LOCALE: available languages can be listed with the 'locale -a' command
    # HARDWARECLOCK: set to "UTC" or "localtime"
    # USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
    # TIMEZONE: timezones are found in /usr/share/zoneinfo
    # KEYMAP: keymaps are found in /usr/share/kbd/keymaps
    # CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
    # CONSOLEMAP: found in /usr/share/kbd/consoletrans
    # USECOLOR: use ANSI color sequences in startup messages
    LOCALE="en_US.utf8"
    HARDWARECLOCK="localtime"
    USEDIRECTISA="no"
    TIMEZONE="Europe/Vienna"
    KEYMAP="de"
    CONSOLEFONT=
    CONSOLEMAP=
    USECOLOR="yes"
    # HARDWARE
    # MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
    # MOD_BLACKLIST: Prevent udev from loading these modules
    # MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
    # NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
    MOD_AUTOLOAD="yes"
    #MOD_BLACKLIST=() #deprecated
    MODULES=(atl1 mii slhc vboxdrv
    !ac97_bus !snd-mixer-oss !snd-pcm-oss !snd-seq-oss !snd-seq-device !snd-seq-midi-event
    !snd-seq !snd-page-alloc !snd-pcm !snd-rawmidi !snd-timer !snd !snd-mpu401-uart
    !snd-ak4xxx-adda !snd-cs8427 !snd-i2c !snd-ac97-codec !snd-ice1712 !snd-ice17xx-ak4xxx !soundcore)
    # Scan for LVM volume groups at startup, required if you use LVM
    USELVM="no"
    # NETWORKING
    # HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
    HOSTNAME="localhost"
    # Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
    # Interfaces to start at boot-up (in this order)
    # Declare each interface then list in INTERFACES
    # - prefix an entry in INTERFACES with a ! to disable it
    # - no hyphens in your interface names - Bash doesn't like it
    # DHCP: Set your interface to "dhcp" (eth0="dhcp")
    # Wireless: See network profiles below
    eth0="dhcp"
    INTERFACES=(eth0)
    # Routes to start at boot-up (in this order)
    # Declare each route then list in ROUTES
    # - prefix an entry in ROUTES with a ! to disable it
    gateway="default gw 192.168.0.1"
    ROUTES=(!gateway)
    # Enable these network profiles at boot-up. These are only useful
    # if you happen to need multiple network configurations (ie, laptop users)
    # - set to 'menu' to present a menu during boot-up (dialog package required)
    # - prefix an entry with a ! to disable it
    # Network profiles are found in /etc/network.d
    # This now requires the netcfg package
    #NETWORKS=(main)
    # DAEMONS
    # Daemons to start at boot-up (in this order)
    # - prefix a daemon with a ! to disable it
    # - prefix a daemon with a @ to start it up in the background
    DAEMONS=(syslog-ng !network hal @dhcdbd @networkmanager netfs @crond @acpid
    @sensors @oss-linux-free @cups @openntpd gdm)
    ..and xorg.conf
    # nvidia-settings: X configuration file generated by nvidia-settings
    # nvidia-settings: version 1.0 (buildmeister@builder57) Thu Jul 17 18:40:12 PDT 2008
    # nvidia-xconfig: X configuration file generated by nvidia-xconfig
    # nvidia-xconfig: version 1.0 (buildmeister@builder57) Thu Jul 17 18:39:19 PDT 2008
    Section "ServerLayout"
    Identifier "Layout0"
    Screen 0 "Screen0" 0 0
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "Mouse0" "CorePointer"
    EndSection
    Section "Files"
    RgbPath "/usr/X11R6/lib/X11/rgb"
    EndSection
    Section "Module"
    Load "dbe"
    Load "extmod"
    # Load "type1"
    Load "freetype"
    Load "glx"
    EndSection
    Section "ServerFlags"
    Option "Xinerama" "0"
    EndSection
    Section "InputDevice"
    # generated from default
    Identifier "Mouse0"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "Device" "/dev/psaux"
    Option "Emulate3Buttons" "no"
    Option "ZAxisMapping" "4 5"
    EndSection
    Section "InputDevice"
    # generated from default
    Identifier "Keyboard0"
    Driver "keyboard"
    Option "Xkblayout" "de"
    EndSection
    Section "Monitor"
    Identifier "Monitor0"
    VendorName "Unknown"
    ModelName "@@@ T19DS"
    HorizSync 30.0 - 81.0
    VertRefresh 56.0 - 77.0
    Option "DPMS"
    EndSection
    Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    EndSection
    Section "Device"
    Identifier "Videocard0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    BoardName "GeForce 8800 Ultra"
    EndSection
    Section "Screen"
    Identifier "Screen0"
    Device "Videocard0"
    Monitor "Monitor0"
    DefaultDepth 24
    Option "TwinView" "1"
    Option "TwinViewXineramaInfoOrder" "DFP-1"
    Option "metamodes" "DFP-0: nvidia-auto-select +1680+0, DFP-1: nvidia-auto-select +0+0"
    SubSection "Display"
    Depth 24
    EndSubSection
    EndSection
    thanks in advance for any help!

    I don’t know that problem, but have you tried if turning off OpenGL and restarting has a bearing on the issue?
    Boilerplate-text:
    Other than that are Photoshop and OS fully updated and have you performed the usual trouble-shooting routines (trashing prefs by keeping command-alt-shift pressed while starting Photoshop, 3rd party plug-ins deactivation, system maintenance, font validation, etc.)?

  • Floating Date/Time in iCal Attachments

    I've been using floating times for our ical attachments and they work great on every device/OS so far except for Blackberry devices. Apparently, Blackberry devices don't properly support the ical standard and interepret floating dates (i.e. w/out the UTC "Z" indicator and without a TZID) as UTC dates and convert them so it ends up being the wrong time on the user's calendar.
    Anyone know if RIM plans on fully supporting the iCal standard to support floating times?
    If you import the following calendar it should import to 8am to 1030 am your local time whatever your local time is, but the Blackberry incorrectly interprets the DTSTART and DTEND to be GMT time and performs a calculation to convert it to local time thereby changing the time to an incorrect time.
    BEGIN:VCALENDAR
    VERSION:2.0
    METHOD:REQUEST
    PRODID:-//CompanyName//NONSGML SiteName//EN
    BEGIN:VEVENT
    CALSCALE:GREGORIAN
    DTSTART:20081009T080000
    DTEND:20081009T103000
    LOCATION:111 Main St\, Roseville\, CA 95747
    DESCRIPTION:
    SUMMARYummary
    TRIGGER:-60M
    UID:[email protected]
    SEQUENCE:3
    DTSTAMP:20081009T192822Z
    PRIORITY:5
    STATUS:CONFIRMED
    ORGANIZER;CN="Test Co":MAILTO:[email protected]
    ATTENDEE;CN="An attenddee":MAILTO:[email protected]
    END:VEVENT
    END:VCALENDAR

    Hi and welcome to the forums!
    Is this in regards to MAC Icals?
    If so, you may be better served to resolve this thread and
    moving to the Blackberry's for MAC forum. I'm sure
    You would get much more specific answers there.
    I have attached what I could find on the subject.
    Thanks
    http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB10501&sliceId=SAL_Pub...
    http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB05175&sliceId=SAL_Pub...
    Click Accept as Solution for posts that have solved your issue(s)!
    Be sure to click Like! for those who have helped you.
    Install BlackBerry Protect it's a free application designed to help find your lost BlackBerry smartphone, and keep the information on it secure.

  • How to convert a datetime value to UTC (or GMT)

    I have this problem.
    The user should provide the following inputs:
    - A date time value - i.e: 10 september 2006, 10:40 AM
    - The world location to which that value refers - i.e.: Rome/Italy
    I need as output, the UTC date time value:
    - i.e: 10 september 2006, 8:40 AM
    in this case it is two hours before because during summer time, the Italian timezone is GMT+2
    And if the user enters:
    - A date time value - i.e: 25 december 2006, 10:40 AM
    - The world location to which that value refers - i.e.: Rome/Italy
    The output should be: (UTC time)
    - i.e: 25 december 2006, 9:40 AM
    It only only one hour before because during winter, in italy the timezone is GMT+1
    In few words I need that Java can do by itself all the calculations about the timezone and daylight saving around different places in the world, so that I can store in my DB the universal UTC time.
    Can you suggest me some code or some good URLs?
    Thanks in advance

    I wrote this code, it works but I have still some issues.
              GregorianCalendar abroad = new GregorianCalendar(TimeZone.getTimeZone("Asia/Tokyo"));
              abroad.set(Calendar.YEAR, 2006);
              abroad.set(Calendar.MONTH, 11);
              abroad.set(Calendar.DATE, 25);
              abroad.set(Calendar.HOUR_OF_DAY, 1);
              abroad.set(Calendar.MINUTE, 0);
              abroad.set(Calendar.SECOND, 0);
              System.out.println(abroad.getTime());
            DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
              df1.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
              System.out.println(df1.format(abroad.getTime()));
            DateFormat df2 = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
              df2.setTimeZone(TimeZone.getTimeZone("America/New_York"));
              System.out.println(df2.format(abroad.getTime()));
            DateFormat df3 = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
              df3.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
              System.out.println(df3.format(abroad.getTime()));          It outputs:
    Sun Dec 24 17:00:00 CET 2006
    luned� 25 dicembre 2006 1.00.00 JST
    domenica 24 dicembre 2006 11.00.00 EST
    domenica 24 dicembre 2006 16.00.00 UTCIn few words this code is able to compute any date from a specific timezone, to other timezone.
    My questions are:
    - Why the first output is in english ? and the other are in italian? (my OS is italian) but I didn't changed the locale in the code, so I don't understand why it outputs english text.
    - When I get the date value in other timezones, I just get a "string" computed by the "format(...)" method of the DateFormat class.
    But I really need to get something "numeric" for every specific value: minutes, hours, day of the month, month, year. Because this class will be used outside java and I don't need a string but something that the user will have formatted in his choosen locale setting for its website. (i think that I was not good to explain this point, i hope that someone can understand)
    However thank you all :)

Maybe you are looking for

  • How can I get  the part image from a rectangle region?

    hi, I'm trying to draw a rectagle region on a picture with mouse and crop it. but the rectangle is not vertical along x-axis.that is to say, there is a angle between x-axis and the base of the rectangle. I don't know , how can I do it. Can someone gi

  • Unable to open pdf files using Internet Explorer and Adobe 9.1

    We are unable to open any/all pdf files in Internet Explorer 6 or 7 using Adobe Reader 9.1 on Windows XP SP2. The error message is that IE has a problem and sorry for the inconvenience. Clicking "OK" closes IE. We did not have any issue with Adobe Re

  • Ports for Macbook Pro to monitor screen

    I just bought a Macbook Pro 2 Ghz i7, 15" laptop and it doesn't seem to have connections(ports) to a separate monitor screen, what can I do? Thanks! Frank

  • Access consignment info records while costing

    Hi I have a valuation variant in which the strategy for material costing has a sequence in which i want to access price from info records while costing thru ck11n or ck40 If i create normal info records,i am able to access the price from info records

  • Can the name of the TASK bound to process level determined dynamically?

    In the 'Complete and Order' step of shopping cart scenario, we can display/ edit agents. This function enable us to see the approver list. In the 2nd column Process Step, there will be a description of the approver, which is the name of the correspon