How convert date with different timezone?

HI,
My problem is pretty simple. I have one Date and given another time zone (as a string), I want to have another date object with a different time zone. I used jodaTime. The code is as follows:
DateTimeZone zone = DateTimeZone.forID("US/Eastern");
DateTime parsedDateTime = DateTimeFormat.forPattern("mm/dd/yyyy").withZone(zone).parseDateTime(dstr);
System.out.println(parsedDateTime.toString());
System.out.println(parsedDateTime.toDate().toString());The output is:
2008-02-14T00:00:00.000-05:00
Thu Feb 14 11:00:00 GMT+06:00 2008
This is quite weird. As is obvious from the output, datetime stores date in the correct timezone. but when converted it to date it applies the jvm's timezone. Why is it so? And why is this time conversion mad e so difficult by providing zillions of classes and methods such as Date, Calendar etc.

amishera2006 wrote:
HI,
My problem is pretty simple. I have one Date and given another time zone (as a string), I want to have another date object with a different time zone. I used jodaTime. The code is as follows:
DateTimeZone zone = DateTimeZone.forID("US/Eastern");
DateTime parsedDateTime = DateTimeFormat.forPattern("mm/dd/yyyy").withZone(zone).parseDateTime(dstr);
System.out.println(parsedDateTime.toString());
System.out.println(parsedDateTime.toDate().toString());The output is:
2008-02-14T00:00:00.000-05:00
Thu Feb 14 11:00:00 GMT+06:00 2008
This is quite weird. As is obvious from the output, datetime stores date in the correct timezone. but when converted it to date it applies the jvm's timezone. Why is it so? And why is this time conversion mad e so difficult by providing zillions of classes and methods such as Date, Calendar etc.for the first question, i can't help you
but for the second one, i guess it's for historic reasons (no defined standard at the beginning lead to a big mess, the same way as with encoding issues)

Similar Messages

  • How to read data with different XML schemas within the single connection?

    I have Oracle 11g database
    I access it through jdbc:oracle:thin, version 11.2.0.3, same as xdb.
    I have several tables, each has one XMLType column, all schema-based.
    There are three different XML schemata registered in the DB
    I may need to read the XML data from several tables.
    If all the XMLTypes have the same XML schema ,there is no problem,
    If the schemata are different, the second read throws BindXMLException.
    If I reset the connection between the reads of the XMLType column with different schemata, it works.
    The question is: how can I configure the driver, or the connection to be able to read the data with different XML schemata without resetting the connection (which is expensive).
    The code to get the XMLType data is textbook implementation:
    1   ResultSet resultSet = statement.executeQuery( sql ) ;
    2   String result = null ;
    3    while(resultSet.next()) {
    4   SQLXML sqlxml = resultSet.getSQLXML(1) ;
    5   result = sqlxml.getString() ;
    6   sqlxml.free();
    7   }
    8   resultSet.close();
    9    return result ;

    It turns out, that I needed to serialize the XML on the server and read it as Blob. Like this:
    1    final Statement statement = connection.createStatement() ;
    2    final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;
    3   ResultSet resultSet = statement.executeQuery( sql ) ;
    4   String result = null ;
    5    while(resultSet.next()) {
    6   Blob blob = resultSet.getBlob( 1 );
    7   InputStream inputStream = blob.getBinaryStream();
    8   result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();
    9   inputStream.close();
    10   blob.free();
    11   }
    12   resultSet.close();
    13   statement.close();
    14
    15   System.out.println( result );
    16    return result ;
    17
    Then it works. Still, can't get it work with XMLType in resultset.On the client unwrapping XML blows up when trying to switch to different XML schema. JDBC/XDB problem?

  • LSMW - Direct Input- RMDATIND- Converted data is different.

    Hi Experts,
    I am working on LSMW - Direct Input- by std. program RMDATIND for material Update,
    When I display converted data, its different than data that I see in display read data step,
    Each time in step display converted data,one perticular record is  displayed.. Even though
    I change input data.
    I like to know why converted data shown is wrong?
    thanks & regards
    Ashish

    Hi thomas,
    thanks for your help....  
    i created 2 materials in file, i.e. with material no. xxxxx2 & material no.xxxxx 3.
    Or even if i created record in iput file with other materila no.
    At each end every time I can see only one converted data record eith Material no. Value = xxxxx1.
    thanks & regards
    Ashish

  • Mix source data with different granularity into the same fact table?

    I have two transaction tables "Incident (157 columns)" and "Unit (70 Colums)". For every "Incident" that happens there could be one or more records in the "Unit" table.
    As part of my data mart design, I have merged both the tables into a single Fact "Incident Fact (227 Columns)" and inserted the records from both the tables with a join condition between them [incident.IN_NUM = Unit.IN_NUM].
    Is this correct, is my question? or am I mixing source data with different granularity in the same fact table. Appreciate your help.
    Best Regards
    Bees

    Bees,
    Are the measures from 'Incident' , repeated for a given incident where it has more than one record in the Unit table ? If so, then the sum(indicent.measure) will give an incorrect result, no ?
    What requirement is there to physically merge the tables together outside of OBIEE? With OBIEE you could have one logical 'fact' table to present to report users, which sourced from seperate Incidents and Units tables and would stop the incorrect aggregations occuring. A common modelling piece in the same way would be Order Headers and Order Lines, quite common in OBIEE to have a logical 'Orders' fact which contained both Order header measures and Order line measures, this translates to your Incidents -> Units relationship.
    To do what I've mentioned, is relatively straight forward, you need a 'Dim - Incident' with two levels, Incident and Unit, mapp the unique identifiers in as the level keys and then use these levels to set the content levels correctly in your 2 logical tables sources for logical 'Fact' , ie Incidents LTS at incident level, Units LTS as units level.
    Hope this helps, let us know if you get stuck.
    Cheers
    Alastair

  • Issue with Java date when different timezone involved

    Hi
    I am facing a problem with java util and SQL date due to different time zones,
    We have a applet which displays data as gant chart( microsoft project type)
    We have our server in NY (EST) which reads data from database (in EST) and sends this data to applet using applet-servlet communication (seralize object)
    This applet gets this date from servlet, does some calculation for pixcels and paints it, but now i am having problem with this calculation, since the date coming is from EST and calendar object in applet is from CST.
    How do i resolve this
    Ashish

    How are you passing the date or doing the calculation?
    I guess you're not using java.util.Date because then would have no problems. The Date class already accounts for different timezones; an instance represents a single moment of time which can be rendered differently depending on the time zone.

  • How to convert date in one timezone to date in another timezone?

    Hi,
    I am building a web site which can be accessed by people across world in different timezones. I have a requirement to collect the data from the users in their respective timezones and convert it to the timezone in which the server is hosted before saving it. E.g. a user in "Kwajalein" timezone (GMT - 12) enters date as "10/23/2007 21:00", the time for the server which is hosted in indian timezone (GMT + 5.30) would be "10/24/2007 14:30". If I use the following program to convert the dates in these timezones it gives me wrong output.
    TimeZone tz = TimeZone.getTimeZone("Kwajalein");
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm");
    df.setTimeZone(tz);
    Date d = df.parse("10/23/2007 21:00");
    TimeZone tz1 = TimeZone.getTimeZone("Asia/Calcutta");
    df.setTimeZone(tz1);
    System.out.println("date in IST-->" + df.format(d));
    The output of this program is
    date in IST-->10/23/2007 14:30
    The formatter has changed the time component however it hasn't changed the date. It still appears as 23.
    Am I doing anything wrong here?
    Please pass your comments.
    Thanks,
    Shashi

    Please see the following link it may be helpfull to you
    1) http://forum.java.sun.com/thread.jspa?threadID=755558
    2) http://myhowto.org/java/36-all-about-locale-sensitive-time-processing-in-java/

  • Collecting same data with different value into a table

    Hi,
    Can you people help me with this problem.
    I have an internal table with different data e.g :
    A    2
    B    1
    C    3
    A    1
    D    7
    B    5
    Now i want to put the values of A,B,C,D into another internal table with some other calculation done.
    But when i am using READ Table with KEY my second internal table is getting filled with A=2 and the second A=2 as well instead of 1.I guess because it is reading the first record only as its finding A first.
    How will i fix this one.
    Kind Regards,

    >
    Prasenjit Sengupta wrote:
    > Hi,
    >
    > Can you people help me with this problem.
    > I have an internal table with different data e.g :
    > A    2
    > B    1
    > C    3
    > A    1
    > D    7
    > B    5
    > Now i want to put the values of A,B,C,D into another internal table with some other calculation done.
    > But when i am using READ Table with KEY my second internal table is getting filled with A=2 and the second A=2 as well instead of 1.I guess because it is reading the first record only as its finding A first.
    > How will i fix this one.
    >
    > Kind Regards,
    Can you tell me the exact requirement of yours?

  • ME51N : how to deal with different units of measure as defined in MM01?

    Hi Folk,
    Could you please help me ?
    Some of our materials booked in stock are purchased by our purchasing department in Europe but as well by our purchasing department in US.
    The base unit of measure of those materials are defined with KG (kilogram) in the masterdata file (MM01).
    Why this is not allowed to enter a purchase requisition (ME51N) with other unit of measure than KG?  My purchasing department in US is not able to work with kilogram and thus they need to enter the requisition with US units of measure (pounds).
    However when we create purchase orders, we can play with other units of measure.
    Does someone can explain to me how to create a PR with a unit of measure different from the default one?  Or could you share your experience to bypass this issue.  Note that we really would like to have the same material number both for Europe and US (with different plants and storage locations).
    Thank you very much!
    François.

    Please check these answered links:
    PR UOM
    Re: Can't Change UOM in PR
    Alternate UOM in PR & PO
    Edited by: Afshad Irani on Jun 14, 2010 7:11 PM

  • 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

  • Multiple channel data with different time stamp logging

    I have peaks and valleys from multiple channels with different time stamp but I am not able to log to a single file. Any idea on how to do this?
    Attachments:
    Single Point Peak Valley Log.vi ‏53 KB

    Hi Dennis,
    Sorry for that I have modified the VI.
    Because the peak and valley of every channel will occur at different time and I want to log the peak/valley with the time stamp.
    How can I log them on the same file.
    Attachments:
    Single Point Peak Valley Log_Mod.vi ‏53 KB

  • How to edit with different formats of clips

    Hi, I am sorry to as this question, I should know the answer but just ain't sure. I am making my reel and I have a bunch of stuff that is dv dvcpro NTSC and that is what the sequence setting is set to. 29.97 compressor is DV DVCPRO-NTSC. However, I have some footage that is DVCPRO HD 720P60.
    When its in the timeline the preview sure makes it look awkward, quality loss. What is the right thing to do here. Also, all my NTSC footage is 4:3, but what does my FC sequence register it as a NTSCDV (3:2) and not NTSC 4:3. Although it looks fine, I just want to understand my timeline settings. Thanks and hope to hear from someone.
    Also, can anyone point me in the right direction to learn how to deal with editing footage with different frame rates. For ex, some 29.97 footage, 23.98/24 Thanks
    Nat

    HI Swarup,
    thanx for the response.
    i did the same thing...i imported 2 different versions into xi and used in mapping.and interface is working fine.
    what i am concerned is : will there be any problem in future while transporting to different environments?
    and why it is showing 'segment version' in attribute in Trace in sxmb_moni....
    any inputs will be help full....
    Thanx in advance.
    regards.

  • How to login with different User in Portal

    Hi Experts,
    My requirment is quite different here, I want to login with different user in single login.
    My senario is like this for your understading...
    First I have loged in with one user and go to the one customized screens where I have list of all the portal users in a drop down.
    Here I am selecting one User from the list and Click on Submit button...then new window should open with this(selected) user login...
    Can anybody suggest me that what I suppose to do this to achieve this.
    what are parameters new user expects for login?
    what 'll be my approach for this?
    Thanks in Advance,
    Vikas

    Hi Prem,
    Thanks for your answer...
    The URL..
    http://server:50000/irj/portal?j_user=QAEmEsLAComR&j_password=Pa$$word
    it works only when, do this on fresh browser .. if someone has already Logged in and then try to open with different user name then it won't work.
    if I'll change URL with other user in the same browser like this..
    http://server:50000/irj/portal?j_user=demouser&j_password=Pa$$word
    then shows only previous page.
    But my requirement is to open different user page from the already logon user.
    Thanks, Vikas

  • How to export/import data with different nls_lang???

    hello
    now i try to run my forms by APPLICATION SERVER to view the forms as web forms i success but data appear unreadable that it is arabic and i use the nls WE8ISO8859P1 so i change the nls to arabic like AR8MSWIN1256 but i faild so i create new database with charset UTF8 and nls_lang is AR8MSWIN1256 and try to insert new data when i do query about data ......the new data appear readable but the old unreadable so what can i do???
    i think that if i do export data and import it with new (charset and nls_lang) it will be success....but how can i do it??
    thank u
    regards

    Hi did you already exported data from SQL SERVER? if not using SQL*LOADER you cannot export data. SQL*LOADER is only mean for importing data from flat files(usually text files) into ORACLE tables.
    for importing data into oracle tables using sql*loader use below steps
    1) create a sql*loader control file.
    it looks like as follows
    LOAD DATA
    INFILE 'sample.dat'
    BADFILE 'sample.bad'
    DISCARDFILE 'sample.dsc'
    APPEND
    INTO TABLE emp
    TRAILING NULLCOLS
    or for sample script of control file search google.
    2) at command prompt issue following
    $ sqlldr test/test
    enter control file=<give control file name which you create earlier>
    debug any errors (if occured)

  • How to change date to different timezone

    Hi - I need to show a date consistantly as eastern standard
    time, but my server is in the midwest.
    Might there be an easier way than testing for 11 to 11:59 PM,
    during which period a day would be added to the current date, or is
    that about all that can be done?

    > Might there be an easier way than testing for 11 to
    11:59 PM, during which
    > period a day would be added to the current date, or is
    that about all that can
    > be done?
    if both tz track DST the same just add the time difference in
    hours to all your
    datetimes when you want to display them. otherwise have a
    look at this
    http://www.sustainablegis.com/projects/tz/testTZCFC.cfm
    but it's probably overkill for your purposes.

  • How to report with different time zone dynamically based on user's account?

    Hello
    I am wondering is there a way to change the report's date & time data based on user's locale setting in OBIEE?
    Let's say the user log in to OBIEE with eastern time zone setting. The data that's in the database is storing a transaction of $400 at 1am Pacific time.
    So when this user run a query which does something like 'select date, transaction, amount from date, transaction, sales where this = that', it should display the $400 amount done at 4am eastern time instead of 1am pst.
    What I have done is to have data stores in date dimension to be UTC time, and I have also changed the data type of the date column to be 'local time zone'. DB is Oracle DB 11G now.
    Now this query works perfectly well in the DB as long as I run the following commend first:
    Alter session set time zone = 'whatever my time zone'
    and then
    Select date, transaction from tables..
    The date displayed will automatically be converted into different time zone..
    Since everything is working nicely from Oracle DB level, I need to know how to make it work when OBIEE sends the same query down to the DB..
    I know that, probably I will have to enter the above alter session commend in the connection pool, however, I can't hardcode the time zone value.
    I also don't want to store user's time zone in the user table because these users travels a lot. So even if his table setting is EST, but at a given day he can be traveling to pst time zone and view reports.
    Is there a way to dynamically set the time zone based on user's account locale setting?
    Let me know if you guys have implemented something similar or not
    Thanks

    garuda wrote:
    Hello Sarvan
    I have already done that part at the DB level and it is working perfectly with alter session commend before the query.
    My question is, how do I configure OBIEE so that before each user runs a report from BI, the alter session commend will be fired with each user's personal locale time zone setting passed through so that each user will be able to view data according to their different time zone?did you tried with Connection scripts(Execute On connect) in Connection pool.write ur Alter commend to Change Time Zone in this script box.

Maybe you are looking for

  • I bought a song on iTunes but now it won't play on my iPhone or my laptop??

    Bout the song Johnny ringo by crown the empire the other day and it was playing just fine and now it won't play anymore. I tried playing it on both my laptop and my iPhone while logged into my iTunes account and it won't play on either. It just skips

  • Display Ipad 4 with problem?

    Hi, under the display of my ipad, in backlight, i see a grid squares. This is usual?

  • Payment Wizard - Recommendation Report - Prints Un-Checked Lines

    Hi, I am running the Payment Wizard and when I get to step 6 (Recommendation Report) I un-check some of the Payments. When I click the Print Preview or Print icon, it previews or prints, but it shows all of the payments that I have, including the un-

  • New to Leopard

    I just upgraded my MPB to Leopard and was reading about Leopard's features. What do I need to run Windows on my computer?

  • CDE and Solaris 8 login problems

    When I attempt to connect to my Sun Ultra80 server running Solaris 8 using Exceed, the CDE login will not display. When I check /var/dt/Xerrors, I see the error message: Server open attempt #0 failed for ws001, giving up Is there a CDE configuration