Time Zone for a particular date/time and location

Hi,
Consider this:
You have some date stored somewhere (e.g. in a database), and it is stored in UTC. Now, you want to display that date in the local time at that particular time, e.g. with or without daylight savings depending on the time of year.
A more concrete example:
In Perth, Australia, daylight savings goes from Dec to Feb inclusive (approx).
Now, you have two dates, say 2007-01-01T12:00:00+0000 and 2007-05-01T12:00:00+0000.
You would like to display these dates as:
2007-01-01T21:00:00+0900 and 2007-05-01T20:00:00+0800 respectively.
However, given that the current timezone today (26th June) in Perth is +0800, they will be displayed as:
2007-01-01T20:00:00+0800 and 2007-05-01T20:00:00+0800 respectively.
Code for displaying in current timezone follows, as a starting point:
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;
public class TimeZoneTestMain
     * @param args
    public static void main(String[] args)
        // UTC timezone.
        TimeZone utcTZ = TimeZone.getTimeZone("UTC");
        // Collection of dates.
        List<Calendar> dates = new ArrayList<Calendar>();
        // Create a date/time - 10 Dec 2005 12pm UTC
        Calendar cal1 = new GregorianCalendar(2005, Calendar.DECEMBER, 10, 12, 0);
        dates.add(cal1);
        cal1.setTimeZone(utcTZ);
        // Create a date/time - 10 Dec 2006 12pm UTC
        Calendar cal2 = new GregorianCalendar(2006, Calendar.DECEMBER, 10, 12, 0);
        dates.add(cal2);
        cal2.setTimeZone(utcTZ);
        // Create a date/time - 10 Apr 2007 12pm UTC
        Calendar cal3 = new GregorianCalendar(2007, Calendar.APRIL, 10, 12, 0);
        dates.add(cal3);
        cal3.setTimeZone(utcTZ);
        displayDates(dates);
    private static void displayDates(List<Calendar> dates)
        DateFormat utcDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        utcDF.setTimeZone(TimeZone.getTimeZone("UTC"));
        DateFormat waDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        waDF.setTimeZone(TimeZone.getTimeZone("Australia/Perth"));
        for (Calendar cal : dates)
            Date date = cal.getTime();
            System.out.println("UTC date: " + utcDF.format(date)
                               + ", WA date: " + waDF.format(date));
}Output is:
UTC date: 2005-12-10T12:00:00+0000, WA date: 2005-12-10T20:00:00+0800
UTC date: 2006-12-10T12:00:00+0000, WA date: 2006-12-10T20:00:00+0800
UTC date: 2007-04-10T12:00:00+0000, WA date: 2007-04-10T20:00:00+0800
I would like the output to be (daylight savings only came in for WA in 2006):
UTC date: 2005-12-10T12:00:00+0000, WA date: 2005-12-10T20:00:00+0800
UTC date: 2006-12-10T12:00:00+0000, WA date: 2006-12-10T21:00:00+0900
UTC date: 2007-04-10T12:00:00+0000, WA date: 2007-04-10T20:00:00+0800
Cheers

>
might be problem with jdk version which you are
using!!!
Mine is jdk 5You are right - just tried with 1.6.0_01-b06 and all is good.
For some reason it didn't occur to me that the other version of the JVM I was using wouldn't have the daylight savings rule, which would make sense since it was released before the daylight saving legislation was introduced by the WA state government!

Similar Messages

  • How to calculate Opening Stock for a particular date.

    Hi Experts,
    I have a sitution to calculate Opening stock for a particular date.
    please help me with the necessary Fields & Tables required.
    Appriciate If any Sample coding available.
    Thanks & regards,
    Venkat.

    Hi Venkat,
    To Calculate Opening Stock & Closing stock there are different procedures.
    It just depends of\n the client requirements & usage of the material.
    For example, we have different types of stocks, like, Through Pipeline, Special, Unristricted, quality, safety,
    and many types of stocks.... so all these types are indicated in MSEG tabe in SOBTZ field,...
    Now Comimg to your Query, You need to calculate OPENING & CLOSING STOCK.
    We have a similiar standard report in MB5B Tcode..
    to get the same results in your report do like this...
    For valuated stock go to the MARDH, MBEWH, MCHBH tables But I Prefer MBEWH.
    here in MBEWH give the month & year and you get the result in LBKUM field...
    For Special stock, You need to go to another table like MKOLH,,(I forgot still 2 more) and
    give the month & year inputs and you will get the result in SLABS field.
    and remaining MB5B refers to its deetails lists with different Movement types,
    whcih you can get clearly from MSEG Table...
    Hope you can write the select Queries accordingly.
    Thanks & Regards,
    Dileep .C

  • How to identify the project in CMOD used for a particular data source

    Hi
      I had a Business Content Data source which is enhanced with ZZ fields and user exit is written in CMOD.
      How can i find in which project used to write the code for that particular data source.....
    When i check CMOD i can find nearly 10 to 20 different projects
    Thanks

    Hi,
    One simple way is goto CMOD and give project names with Z* or Y*. First findout the naming convensions following in  your project and see.
    Then gibe projects one by one and select COMPONENTS option and click on Display, if you find the following Function Exits means it is our DataSource project
    EXIT_SAPLRSAP_001
    EXIT_SAPLRSAP_002
    EXIT_SAPLRSAP_003
    EXIT_SAPLRSAP_004
    Thanks
    Reddy

  • Stock in transit for a particular date

    Hi all,
    How to find the stock in transit for a particular date.
    In MB5T date option is not available.
    Is there any other way or i need to gofor Z development.
    Kindly help me in this regard.
    Regards
    KK

    Try MB5TD. Please also check OSS notes 1120843, 1268193, 925384.
    Edited by: Csaba Szommer on May 22, 2009 8:28 AM

  • Creating Planned orders and Requisitions for a particular MRP controller and for all the others only Requisition is to be created.

    Hi Experts,
    Currently we run Program 'RMMRP000' as a batch job to create Planned orders and requisitions.
    The client wants that Planned orders and Requisitions should be created for a particular MRP controller and for all the others only Requisition is to be created.
    I implemented Exit 'EXIT_SAPMM61X_001' in the following manner by passing MRP controller to user_key.
      IF mt61d-dispo <> user_key.
        no_planning = 'X'.
      ENDIF.
    But as you can see that this will not meet my client requirement.
    If any of you has worked on similar requirement / if any one knows that this is achievable or not,
    please share your inputs.

    Moved from SAP ERP Sales and Distribution (SAP SD) to ABAP Development
    G. Lakshmipathi

  • 220MB of Time and Location in Cellular Data ?

    Since upgrading to an iPhone 5s from a 5 (although still using iOS7) I noticed my data plan use accelerated and couldn't account for it with changed use spending less time on WiFi etc. I turned off background downloading of app updates and a couple of the other battery saving tips I have seen posted.
    So under System Services I see by far the biggest hog is this 220MB - is this something core to the OS that I can disable or is it being "used" by another application which doesn't show such high use in its own totals. The largest next one is Google at 9MB.
    Is there anything finer granularity than just turning off Location Services ? Any suggestions to find out what keeps checking the time or location ?

    I am wondering the same thing. This single category has used 25% of my cellular data for the current billing cycle with my cellular provider.

  • On iPhone 6, How do I display the date, time, and location where a photo was taken

    On my previous iPhone (4S), I used the "Info' option in iPhoto to see where and when a photo was taken. I have a new phone (iOS 8.3) and iPhoto is not supported, so I have to use the Photos app. I cannot figure out how to see where and when a photo was taken in the Photos app. Thanks for any insight anyone can provide.

    Hello there, marklewis.
    When wanting to find location information of photos on your iOS device in iOS 8, the online User Guide provides some great information for how to search:
    View photos and videos - iPhone
    View by location. While viewing by year or by collection, tap . Photos and videos that include location information appear on a map, showing where they were taken.
    While viewing a photo or video, tap to show and hide the controls. Swipe left or right to go forward or backward.
    Search photos. From Albums or Photos, tap to search by date (month and year), or place (city and state). Search also keeps your Recent Searches on hand and gives you a list of suggested searches.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Calculate funds available for a particular date

    Hi,
    I am developing a custom PO Printing report and there is a requirement to calculate the budget/funds available for a particular account as a column in the report. Oracle has given the standard package gl_funds_available_pkg.calc_funds to calculate funds available. But this gives funds available for a particular account as on date. However my requirement is to print the funds available as on purchase order approval date,while the custom report might be generated at a later date. Many transactions would have been done using that account and the funds available would have reduced as on report generation date. But I need to get the funds available as on po approval date(earlier date).Please help me achieve this requirement.

    Hi Venkat,
    To Calculate Opening Stock & Closing stock there are different procedures.
    It just depends of\n the client requirements & usage of the material.
    For example, we have different types of stocks, like, Through Pipeline, Special, Unristricted, quality, safety,
    and many types of stocks.... so all these types are indicated in MSEG tabe in SOBTZ field,...
    Now Comimg to your Query, You need to calculate OPENING & CLOSING STOCK.
    We have a similiar standard report in MB5B Tcode..
    to get the same results in your report do like this...
    For valuated stock go to the MARDH, MBEWH, MCHBH tables But I Prefer MBEWH.
    here in MBEWH give the month & year and you get the result in LBKUM field...
    For Special stock, You need to go to another table like MKOLH,,(I forgot still 2 more) and
    give the month & year inputs and you will get the result in SLABS field.
    and remaining MB5B refers to its deetails lists with different Movement types,
    whcih you can get clearly from MSEG Table...
    Hope you can write the select Queries accordingly.
    Thanks & Regards,
    Dileep .C

  • Production Hours of a workcenter for a particular date

    Greetings,
    Is there any reports for getting the production hours of a workcenter on a particular date?I would like to get the
    schedule summary.The output must contain date and hours.
    Helpful answers will be rewarded.
    Regards,

    Hi Jinesh,
    You can use MC10 - Flexible analysis for your requirement.
    For this you have to create/change your own Evaluation using MC11/MC12 transaction.
    Reward points if helpful
    Regards,
    Arpit

  • Need to create a report to show values for a particular date range

    I have to create a report, out of which I need two columns : << Customer Value Variance and Churn Score Variance >> to show values only for a custom date range, which will be entered via a dashboard prompt.
    These generic date columns are not present and cannot be added. I have to make use of Pres variables
    What I have currently done is:
    1) Created a prompt with 2 different date columns and passing those values into variables vStartDate and vEndDate. (I don't actually need those 2 column which I have selelcted, but I have taken those so that I can prompt the values in calendar format and pass onto the variables)
    2) Created report with necessary columns, with 2 extra columns (hidden) as vStart Date Column and vEnd Date Column which take the values from the presentation variables defined in the prompt. I have created these columns as then I can reference these in the two required columns if necessary.
    I am already facing error in report after doing this and I am confused how to proceed. Any suggestions?
    Thanks.

    Yes, but it only has one generic Date column, no start date and end date. I can't use that twice in the prompt. Although I can specify it to be 'between', but I'm not sure I can pass values to both variables like that.
    Currently I have used Campaign Start Date and Campaign End Date to enter values in calender format to the variables.

  • Can you search for a particular date in the past to locate a file in the time machine

    Using a MacBook, OSX 10.7.5
    Is there a way to go back to a certain date in the history of the time machine?  Example - is there a quick way to go back to Oct 25, 2012?
    Thanks.

    All you could ever need to know about Time Machine:
    http://pondini.org/TM/Home.html
    (from the late and sorely missed ASC contributor Pondini)

  • I have a MacBook and cannot connect to App Store. I have no problem with the internet connection. I want to be able to buy the apps that are available for my computer. The date, time and location are all correct - all the suggestions have failed

    I have a MacBook - I am unable to connect to App Store - I have no problems using the internet to connect to anything else. I have checked out all the suggestions - Apple Preference and time, date, location etc. they are all correct. I cannot think what else I should do. Any suggestions please Cynthiafromgrayshott.

    If you don't see any messages, not have anti-malware running or the Firewall on, try installing the Mac OS X 10.6.8 Update Combo
    It's ok to do this even though you are already running v10.6.8 (according to your profile).
    Restart your Mac after the combo in installed, try the App Store.
    Also... if you have an app called Little Snitch installed, that can prevent a connection to the App Store.

  • Date Time and location is showing wrongly

    Hi , running iPhone 4S on O2 network in UK and noticed today that the time has changed to TBILISI when set to 'Set Automatically' and when I look in google maps for my current location it shows me as being somewhere in Russia - any suggestions?

    Don't know the fix but you're not alone.  Here's a thread you can read through:  https://discussions.apple.com/thread/3463431?tstart=0

  • Source for Init with data transfer and full load

    Hi Experts,
    1. Please tell me where the data comes when we do the
        following actions :-
        a) Init with data transfer
        b) Full load
      i want to know the source of data i.e (setup table or main table or any other table)
    Helpful if you can provide the data-flow.
    kindly tell which is prefrable and why?
    Regards,
    RG

    Hi.......
    When you do init with data transfer it will read data from the set up table only..........but beside this it will also set the init flag..........due to this from next time any new records will go to the delta queue...........and next time when you run delta load it will pick records from delta queue...........
    Now suppose data are alrady available in the BW side...........then you can run init without data transfer.......this will only set the init flag.........it will not pick any records.........
    Extraction structure gets data from set up table in case of full upload ............and in case of delta load from delta queue.......
    Regards,
    Debjani...........
    Edited by: Debjani  Mukherjee on Sep 20, 2008 11:45 AM

  • How are attributes and texts for a master data linked and targeted to ...?

    Our previous consultants used to load data to master data 0MATL_GROUP. 
    1. RSA1 -> InfoProvider -> Select 0MATL_GROUP or 0MATL_GROUP___T
    Check these above two and find the records loaded are both 1,216 for Language EN.
    We check the data flow of this master data (0MATL_GROUP or 0MATL_GROUP___T) and find there are four branches which target 0MATL_GROUP:
    branch 1: 0MATL_GROUP is itself an InfoSource and the datasource is 0PROD_CATEG_R3_MAP_ATTR.  However under this datasource, there is no any InfoPackage, i.e., the system doesn't load data to 0MATL_GROUP through this branch.
    branch 2: Through InfoSource 0MATERIAL_ATTR.  However the InfoPackage under this InfoSource target data load to 0MATERIAL but not 0MATL_GROUP, i.e., the system doesn't load data to 0MATL_GROUP through this branch.
    branch 3: Through InfoSource ZMATL_GROUP_ATTR and it's corresponding datasource Z_MAT_GROUP_ATTR.  InfoPackage monitor shows the data load record for this datasource is 490 (Run RSA3 on R3 for this datasource also gives the same record count).
    branch 4: Through InfoSource 0MATL_GROUP_TEXT and it's corresponding datasource has the same name. InfoPackage monitor shows the data load record for this datasource is 1190 for Language EN (RSA3 on R3 for this datasource gives the same count for language EN).
    2. InfoObj. 0MATL_GROUP
    1). Master data tab (/BI0/PMATL_GROUP): 526
    2). Text table (/BI0/TMATL_GROUP):
    1657 (includes both EN and other lan-guages), for EN: 1190.
    3. Check R3 Table T023T (Material Group Descrip-tions) for EN: 1190.
    Our questions are:
    1. The InfoProvider 0MATL_GROUP and 0MATL_GROUP___T
    both have counts of 1,216 for Language EN.  And for the four branches in the data flow, only 3rd and 4th branches feed data to it.  3rd branch (datasource Z_MAT_GROUP_ATTR) feed count is 490 and 4th branch (datasource 0MATL_GROUP_TEXT) feed count is 1190 for Language EN. We wonder how attribute and text data are corelated to each other and with it's master data.  Obviously 1,216 is not equal to the sum of 1190 and 490, the how 1190 (text) and 490 (attribute) constitute the master data count 1,216?
    2. Do we have to use 1st and 2nd branches to feed data to 0MATL_GROUP?
    3. How InfoObj. 0MATL_GROUP Master data tab (/BI0/PMATL_GROUP) shows the count is 526?  it should be 490 from the custom datasource Z_MAT_GROUP_ATTR, right? But why the count is different?
    We would be appreciated any expert input!

    Kevin,
    can you check the data in Material Group charecterstic againest R/3. One moe thing check how these 4 branches Mapped to material Group?
    Take the for Attributes it should be 490. it is 525. try to analyse what are the extra records comparing with Source. take the you found so and so meterial group extra then analyze from where is it getting extracted to BW i mean which DS.. (either branch 1 or brach 2 or branch 3 or 4). then check in R/3 side DS for the 4 branches. then you will know what exactly happening.
    Analyze the data from step by step from r/3 to BW for each level. You will get clue.
    Nagesh.
    Message was edited by: Nagesh Ganisetti

Maybe you are looking for

  • Is my mid 2010 macbook pro compatible with apple tv?

    I just purchased apple tv and am having trouble with airplay are mirroring?  I need to know if my mid 2010 macbook pro and ipad 2 are compatiable?  Because so far the only thing i am able to get on my apple tv is my music.  I am unable to mirror any

  • Help in understanding GUI's!!!

    Hi everyone, I'm new to this type of forum, but I figured it can't hurt to ask for help wherever I can find it. I'm in a Java II class right now, and I'm having a hard time understanding how to build a GUI. I created the programs provided in the book

  • External hard drive becomes "read only" and won't let Time Machine back up

    I have an external hard drive for back up, and it has been working fine until recently. There is a version of 10.6.6 loaded on it also. The back up will fail every few days. When I do some checking, the back up drive is "read only" but I am not able

  • Scrubber works in test; not after "Publish"

    Following Lee Brimelow's tutorials, I have flv video running nicely with controls and a scrubber bar. When I test the movie, the scrubber works perfectly. But after I publish it and try it in the browser, it looses one functionality: The video image

  • Missing desktop  icons

    On turning on my MBP today I notice all the desktop icons were missing including the H/D icon. The menu bar still displays correctly and the screen is correct. How can I get back my desktop icons? I've tried preferences, restarting, looking to see if