Calendar/Date TimeZone conversion

Hi,
I am having problems trying to print a date. I am in the West Coast of the US and I want to display a specific time in GMT format. Unfortunately, the time is being displayed in PST and I cannot understand why. Here is what I'm doing:
I have created a Calendar object and set the year, month, day, hour, minute and second set to specific values. Before I set these values, I set the TimeZone for this Calendar object to GMT.
I am using the following piece of code to format this date in order to display it
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(date_.getTime());
date_ : this is my Calendar Object
I think when I call the getTime() method, my system converts the time in GMT format back into the local system time format (ie PST). How can I get around this problem?
I would really appreciate any help from anyone.
Cheers.

Here's what makes the difference. Instead of setting the time zone for the calendar instance try setting for the DateFormat instance. It will definetely work.
- Nirmal R.
Hi,
I am having problems trying to print a date. I am in
the West Coast of the US and I want to display a
specific time in GMT format. Unfortunately, the time
is being displayed in PST and I cannot understand why.
Here is what I'm doing:
I have created a Calendar object and set the year,
month, day, hour, minute and second set to specific
values. Before I set these values, I set the TimeZone
for this Calendar object to GMT.
I am using the following piece of code to format this
date in order to display it
return DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.SHORT).format(date_.getTime());
date_ : this is my Calendar Object
I think when I call the getTime() method, my system
converts the time in GMT format back into the local
system time format (ie PST). How can I get around this
problem?
I would really appreciate any help from anyone.
Cheers.

Similar Messages

  • Calendar, Timestamp, TimeZone and DateFormat

    I need to persist date and time with a time zone information into database. In the application, I use the Calendar to represent the data and converse it to java.sql.Timestamp when I need to store the date into DB, use its reversed process to retrieve the data. The following process works for my need in some degree.
    1. create a Calendar instance
    2. convert it to Timestamp to match the DB field type and save into DB
    3. retrieve the field from DB and convert back to Calendar (from Timestamp)
    4. process the data with DateFormat for a given TimeZone GMT
    My problem with the above approach is that it yields an incorrect data when a date time in DB is already in time zone GMT stored by another system process.
    What is a good approach in the regard?
    Thanks for your information in advance.

    Isn't Timestamp always "in UTC"? If you want to remember a TimeZone, would you need to store that separately?
    Then again, I have this vague recollection there's a database type that combines timestamp and timezone, but does your DBMS have it?

  • Urgent : Timezone conversion issue

    Hi,
    I am having an issue in timezone conversion.Im trying to convert a date type value to server timzone before insert into table. Im writing the conversion code in validateEntity(). Im using OANLSServices methods for conversion.Since i have to pass java.util.Date to this convertTimezone() as first parameter(date to be converted),im converting the reqd date which is in oracle Date type to java util Date type. Function is returing java.util.date type, which is again converted to oracle Date type. then im passing this value to the setMethod, ie., setJoiningDate(Date ) in my case.
    the code is compiled with 0 errors. But wen i run the page and after entering date value and click save button , its throwing some exception like "oracle.jbo.ValidationException: JBO-28200: Validation threshold limit reached. Invalid Entities still in cache"
    and in the debug console, this code in the validateEntity() is executed 10 times. First time it is converting the date time value to date only format, then same this is executed 9 more times. Can anyone help to resolve this issue? Its very urgent.
    Thanks
    Harsha

    Harsha,
    Use this code and try again...!
    oracle.jbo.domain.Date join = getJoiningDate();
    // to convert oracle Date to Java util Date
    java.sql.Date joinSql =(java.sql.Date)join.dateValue();
    java.util.Date jdateUtil =
    getOADBTransaction().getOANLSServices().convertTimezone(joinSql,
    getOADBTransaction().getOANLSServices().getUserTimeZoneCode(),
    getOADBTransaction().getOANLSServices().getServerTimeZoneCode());
    // to convert back to oracle Date
    java.sql.Date jdateSql = new java.sql.Date(jdateUtil.getTime());
    oracle.jbo.domain.Date jdate = new oracle.jbo.domain.Date(jdateSql);
    setJoiningDate(jdate);
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Confused with Calendars and TimeZones

    Hi, I'll explain what I want to do. I have a table with several of what I call a "Time Ranges". Each Time Range has a day (day of week), beginTime and endTime. I also have different clients, each from a different country. Each client has a timezone associated (the format of this timezone is not defined just yet, but it should be something like -3, -4, +1, etc).
    I want to get the current date, and be able to figure out if it is within a certain time range. For example, right now in Argentina is
    11:48 AM GMT-3
    This should match these time ranges:
    11:00~12:00 | -3
    10:00~11:00 | -4
    13:00~14:00 | -1
    And should not match this time range:
    11:00~12:00 | -4
    I'm trying to get the "current time for a certain time zone" with Calendar, and then be able to extract the time from that Calendar and compare it with my beginTime and endTime. I'm not getting anywhere.
    Something like this:
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-08:00"));
    System.out.println(cal.getTime());Is printing GMT-3 time. Please help.

    manugarciac wrote:
    Ok, I did it like this. The TimeRange Class has this method:
    public boolean isActive(String timezone) {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timezone));
    if (cal.get(Calendar.DAY_OF_WEEK) == this.day) {
    Time time = new Time(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), 0);
    return (beginTime == null || time.after(beginTime)) && (endTime == null || time.before(endTime));
    return false;
    }Timezone should come in this format: "GMT-04:00" and Time is java.sql.Time.
    The only downside is that the Time constructor I used is deprecated. It says I should use the one that uses milliseconds since 1970. That kinda sucks, as I don't really care how much time passed since that time for this time. Any ideas of what I should use?forget java.sql.Time. use Calendar.set(int year, int month, int date, int hourOfDay, int minute) to set beginTime and endTime. use Calendar.compareTo(Calendar anotherCalendar) for the test.
    Edited by: pete_d on Sep 10, 2010 3:09 PM
    Not sure exactly what's going on in your TimeRange class but if the hour, minute, second and time zone in addition to the day of week (it seems that it does) for both begin and end time, then you can use this to create a Calendar instance to compare with the current time or to whatever other Calendar instance you want to check using its year, month day.

  • HT204452 Calendar Date Issues

    I really don't know what's happened to OS X --other than changes to make the system complicatedly 'user friendly' and at times impossible to use, (literally). Apple's fully overhauled the system and made major changes to break functional applications, including Finder.
    Anyway, my issue is with one of their apps which hasn't been the same since SL, although I'm pretty sure SL was light-on for features too.
    Does anyone know how to fix the Calendar? Going into System Preferences to start a week on a Monday in Mavericks shifts the weeks to start on a Monday. Yay! What it should do. Although, it doesn't shift the date numbers, (one per square in the upper right corner when viewed in month view); it forgets to shift the day names -- which are fixed to the title bar at the top of the page.
    I know enough to submit a bug report, but honestly I wondered how anyone could overlook such an obvious feature that without this problem (confirmed) in releases prior to Lion.
    I for one hate the Calendar now among many apps on Mac OS X, and if I wasn't so invested in the ecosystem, their down-grades with each subsequent release would have converted me over already. It's pretty disappointing when I go back to my old iMac and notice how much more I prefer Leopard and the way Apple was.
    Ed

    I just wanted to add that I did some more testing
    it looks like this is the function that is slower.
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    maybe jre1.3 only keeps around 1 instance of the utc timezone, and jre1.4 is create a new instance each time getTimeZone("UTC") is called.

  • Oracle timezone conversion

    I have a requirment in which the database server time is being changed to GMT but one of the database users needs to store its data in CST or CDT as the case may be depending on daylight savings .I am thinking of writing a function which returns depending on date value passed on to it whether it is CST or CDT (depending on the day of the year ) and thiS function would be called from a before insert trigger for the tables so that the date data being passed on GMT time is converted back to CST or CDT before storing and stored as such then .Is this the best approach ,does oracle have a system function for this ? NEW_TIME is the function that I am aware of for timezone conversion however it doesnt take into consideration if it is CST or CDT .Thanks

    What is the datatype - date, timestamp, timestamp with timezone?
    There are ways of converting the date which includes daylight savings time considerations;
    SQL> select sessiontimezone from dual
    SESSIONTIMEZONE
    -08:00        
    1 row selected.
    SQL> create table t(ts timestamp)
    Table created.
    SQL> insert into t values(to_timestamp('01-jun-2007 12:00:00', 'dd-mon-yyyy hh24:mi:ss'))
    1 row created.
    SQL> insert into t values(to_timestamp('01-dec-2007 12:00:00', 'dd-mon-yyyy hh24:mi:ss'))
    1 row created.
    SQL> SELECT ts,
       ts AT TIME ZONE 'UTC' utz,
       ts AT TIME ZONE 'Canada/Central' ctz
    FROM t
    TS                         UTZ                               CTZ                             
    2007-06-01 12:00:00,000000 2007-06-01 20:00:00,000000 +00:00 2007-06-01 15:00:00,000000 -05:00
    2007-12-01 12:00:00,000000 2007-12-01 20:00:00,000000 +00:00 2007-12-01 14:00:00,000000 -06:00

  • Date difference when converting Calendar date to sql date

    I am trying to convert a Calendar date to sql date. The only problem in the conversion is sql date adds 1 month to the original date. Due to this my query results show different data than what it is suppossed to show.
    Here is my code
    Calendar startDate = Calendar.getInstance();
    startDate.set(2006, 10, 01, 00, 00); // 1-Oct-2006
    return (new java.sql.Date(date.getTimeInMillis()));
    on the last statement it adds a month to original date. So the final date i get is 1-Nov-2006.
    Any solution to this problem?
    Thanks
    Sameer

    Thanks everyone for quick response.
    I have read javadocs many times but that does not
    change the fact that Calendar and Sql date
    interpretation is different.No, it isn't. You are setting the moth to november when you set the month to 10, and november is what java.sql.Date is showing. So where is the difference? You are doing it wrong and that is why you get the wrong month.
    How the f do you think that the calender should know that you want october when you set it to november?
    My application is deployed through web service and
    the clients may access it through any programming
    langague (java, php, ec). Even I am testing it
    through java and php. Still doesn't matter. You need to subtract the month by one if you want to let your user use 1 for january.
    While testing it through java month is different but
    through php its correct.Read the docs.
    Can smoeone please give me the best possibel solution
    to this?see above

  • How can I get missing contacts, notes, calendar dates and reminders that are just on my old iphone onto the iCloud for transfer to my new iPhone upgrade?

    Dear wise & wondeful people:
    How can I get missing contacts, notes, calendar dates and reminders that are just on my old iphone onto the iCloud for transfer to my new iPhone upgrade? Half of my contacts, notes, ect. were on my iCloud so have happily moved to my new iPhone but the rest are completely resistant. For example, on my iCloud I have 14 missing contacts starting with the letter A alone, however they are happily viewable on my old iPhone 4S and won't budge over into the iCloud.
    There are also 3 notes missing yet still acessible on my onld iPhone 4S, the list goes on.
    Your help would be most appreciated. Thank you so much.
    BCHR

    Hi BCHR,
    If you are having issues transfering your content from your old iPhone onto iCloud so it can be transfered to your new iPhone, you may find the following articles helpful:
    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device
    http://support.apple.com/kb/HT2109
    iCloud: Troubleshooting iCloud Contacts
    http://support.apple.com/kb/TS3998
    iCloud: Troubleshooting iCloud Calendar
    http://support.apple.com/kb/TS3999
    iCloud: Notes overview
    http://support.apple.com/kb/PH12081
    Regards,
    - Brenden

  • ITunes Calendar data doesn't match Outlook's.  How can I fix?

    I have a new iPhone and just recently discovered that the Calendar is not updating, 
    probably since the first time I synced.  And even then it was using old calendar data which 
    doesn't currently show up in Outlook.   (Contacts sync perfectly.)  Applecare took me 
    through their 1st and 2nd-level support troubleshooting and said they couldn't do anything more.  
    They suggested possible corruption of outlook.pst. 
    One glaring example: I used to have 3 calendars in Outlook: "Bridge", "Calendar" and 
    "Others".  I recently deleted all but the one called Calendar, but all 3 still show up in 
    iTunes, even though I've uninstalled/reinstalled iTunes twice.  Only "Calendar" shows up on 
    the iPhone, but it has old data.  I think the data it's displaying has not been refreshed 
    since 9/23/11, when I moved the outlook.pst file to a location in My Documents for easier 
    backup, but that doesn't really make sense since the Contacts update just fine.  (I've had 
    an iPad for about a year, and it's behaving the same as the iPhone now; the Calendar used 
    to update properly.)  Another possible clue: the iPhone shows two instances of one 
    particular recurring appointment.  I don't recall ever having two instances of it in 
    Outlook and wonder if that could be the problem.  I removed it altogether from Outlook and 
    that didn't help.
    I've done extensive testing with a new Windows user account and Outlook, and the calendar 
    syncing seems to work fine.  I've Googled "iPhone calendar won't update" and similar and
    haven't found anything that works for my situation.
    I'm running Office 2003 on Windows XP.  I do NOT use Outlook for mail.

    I was having the same problems after downloading 10.4.1 IStore would only download half way then nothing attempted reinstall no goood checked the Diagnostics with IPad connected, indicated no errors. more than a few hours browsing possible solutions. Found one stating 'Remove all Itunes connected software, i.e. Bonjour, ITunes, Safari etc from PC via the Uninstall Safely Feature and ReInstall. Hey Presto it worked now no issues.
    Good Luck. I am using Windows 7.
    That's my problem exactly, but I can't find the: ''Uninstall Safely Feature and ReInstall''. Where is that??
    Thank You

  • HELP - I've lost all my Calendar data, most of my Notes, and other issues

    In priority order:
    1.  Sometime in the last two days my iPhone 4S, with IOS 7.0.4, lost all my Calendar data except birthdays from Contacts.
    2.  Most of my Notes are lost except those from PC.
         WRT the above, iPad data is still intact.  
    3.  IOS 7.0.4 crashes apps A LOT! Even Apple apps.
    4.  IOS 7.0.4 is slow.

    Resolved items 1 & 2 by rebooting the phone.  I am happy that it resolved, but it shouldn't have happened n the first place.

  • HT1296 I have a problem synching calendar data between my iPhone 3GS iOS 5.1 & Outlook 2007 on MS7.  The basic calendar is OK but the birthdays (little box icon) are a day early & cannot be changed to the correct date. How can I fix this?

    I have a problem synching calendar data between my iPhone 3GS iOS 5.1 & Outlook 2007 on MS7.  The basic calendar data transfer is OK but the birthdays (little box icon) are a day early & cannot be changed to the correct date. The birthday entries in my Outlook contacts have correct dates.How can I fix this?

    The following peocess corrects the calendar entry:
    edit the contact & change the birthday, save the change; edit the contact & change the birthday to the correct value, save the change again. The calendar entry then displays on the correct date.  Alternatively as a temp solution I can just de-select the "birthdays" calendar which stops the icon being displayed.
    Thanks for your advice, I think that it's n going to be a slow process to fix all the entries for not much return.

  • Working day to factory calendar date

    Hello Experts,
    I wish to get the factory calendar date, specific to a factory calendar, based on a working day.
    Basically, if i pass say 4, then i want to get the date for the 4th working day based on a specific factory calendar.
    Can someone throw some light on possible function module that i can use in BW ?
    Thanks

    That's what I was giving you, you give the working day and the factory calendar and you get the date, or you can use this function and you can do it the other way:
    (Unless I'm completely missing your point here...)
        CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
      EXPORTING
        CORRECT_OPTION                     = '+'
        DATE                               = G_WORKAREA3-CREATEDON
        FACTORY_CALENDAR_ID                = L_S_PLANT-FACTCAL_ID
      IMPORTING
    *   DATE                               =
       FACTORYDATE                        = L_FCDATE
      EXCEPTIONS
        CALENDAR_BUFFER_NOT_LOADABLE       = 1
        CORRECT_OPTION_INVALID             = 2
        DATE_AFTER_RANGE                   = 3
        DATE_BEFORE_RANGE                  = 4
        DATE_INVALID                       = 5
        FACTORY_CALENDAR_NOT_FOUND         = 6
        OTHERS                             = 7.
      ENDIF.

  • ICal sycing calendar dates to iPhone

    Hi,
    When I plug the iPhone into the mac via USB and open iTunes, the calendar dates in iCal do not get synced across. I have gone into iCal and looked for a way to send dates to the phone, but without success. Can anoyone help, please? iTunes does send contacts - just not iCal dates.
    Thanks!

    I finally got it fixed with a little help from some related posts online.
    - Delete any files with 'cache' in the name that are in ~/Library/Calendars
    - Launch iSync, go to Preferences, and do Reset Sync History
    - Log out and log back in
    I don't know if it's one or both of the first two items, but it did the trick.

  • The contacts and calendar data on my iPod touch will not sync with my Mac

    I have a 2nd generation ipod touch, and an iMac running iTunes 8.2.1.
    I have been away from my mac for a few months and have entered a lot of contact and calendar info into my ipod touch.
    Now, when I try to sync the contacts and calendar data on my ipod touch with my mac, the data will not sync to my mac.
    Similarly, for the last couple months, the contact and calendar data on my ipod touch has not been able to sync with my mobileme account.
    I cannot afford to lose the contact and calendar data on my ipod touch.
    Can anyone kindly inform me how to fix this syncing problem without losing such data?

    DGKSA wrote:
    I ended up entering the data onto my Mac, then nuking my iPod touch with a restore.
    So, there is no need to respond to my question.
    You can also mark your post as "solved" if you solved your problem on your own.
    Only the original topic poster has the option to mark replies as either Helpful or Solved or to not mark a reply at all. The originator can also end the discussion by marking the topic as "answered," which displays a green star at the top of the topic page to let everyone know that the topic contains valid helpful information.
    copied from "Terms of Use"

  • Some calendars in iCal appear corrupted but OK on iPhone. If I sync will the calendar data on the phone restore info on the desktop iCal? any other ideas for how to sort this please?

    Some calendars in iCal appear corrupted (ie have red exclamation mark by them) but are still OK on iPhone. If I sync, will the calendar data on the phone restore info on the desktop iCal or will I lose that as well? Or could I back up the calendars on my iPhone somewhere and then import them into iCal? any other ideas for how to sort this please? it's driving me mad. thanks.

    I don't think there will be a solution to this. Exchange 2003 just isn't supported.

Maybe you are looking for

  • Why can't I see PDF files in Safari with new Lion OS?

    I installed Lion. Now when I click on bank statements and forms that are attached to web pages, they come out black! Like this one: http://www.whitewaterchallengers.com/lehigh/waiver_form.pdf JS

  • Thunderbolt and motu 8pre

    Hi Does anyone know how to get the MOTU 8pre to work with a Firewire 400 to 800 and Thunderbolt adapter on a 2.7 GHz Intel Core i5 Imac? Motu support suggest a 400 -800 cable but I have tried this and it just doesn't work!!

  • Need table name used for storing web dynpro methods' code.

    Hi experts, I am trying to retrieve the code of a particular web dynpro component's methods. So can anyone please tell me the table in which the code or logic part  of the methods are stored????????? Thanks in advance..... Edited by: Adithya K Ramesh

  • Mail for Exchange Stopped Working

    After a Successfull migration from Exch 2003 to 2007 RPCOverHTTPS Works OWA Works ActiveSync over a PPC5.0 Device Works Only Mail for Exchange 2.1 on my Nokia E65 (Which i use the most) stopped Connecting Address\Security hasen't changed Did anyone e

  • ADO Stored Procedures Error message

    I am having trouble using Oracle Stored Procedures with ADO. I keep getting an Run-time 3708 - Parameter object is improperly defined. Any advice welcome. This is my VB Code: Set myCommand = New ADODB.Command With myCommand Set .ActiveConnection = my