How to set the timezone in a DATE datetype?

How to set the timezone in a DATE datetype?
Thanks
Maximus

10.5 Date, Time, and Timestamp
The JDBC API follows the Java platform's approach of representing dates and times as a millisecond value relative to January 1, 1970 00:00:00 GMT. Since most databases don't support the notion of a time zone, the JDBC 2.0 API adds new methods to allow a JDBC driver to get/set Date, Time, and Timestamp values for a particular time zone using a Calendar. For example,
ResultSet rs;
Date date1 = rs.getDate(1);
returns a Date object that wraps a millisecond value which denotes a particular date, like January 3, 1999, and a normalized time 00:00:00 in the default time zone. The time component of the Date is set to zero in the default time zone since SQL DATE values don't have a time component. Since a Calendar was not supplied explicitly to getDate() , the default time zone (really the default Calendar) is used by the JDBC driver internally to create the appropriate millisecond value assuming that the underlying database doesn't store time zone information.
The following example retrieves a date value in GMT-Greenwich Mean Time.
ResultSet rs;
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
Calendar cal = Calendar.getInstance();
Date date2 = rs.getDate(1, cal);
In the example above, a Calendar is passed explicitly to getDate() to inform the JDBC driver how to calculate the appropriate millisecond value. Note that the same result could have been achieved by simply changing the default time zone, and not passing the Calendar explicitly since the JDBC driver will use the default time zone by default.
Note that the two Date objects created above will not compare as equal assuming that the default time zone is not GMT, even if they represent the `same' date.
if (date1.equals(date2))
//never get here
This is because each Java language Date object really just wraps a normalized millisecond time value and these millisecond values will differ across time zones. If an application wishes to compare dates in different time zones it should first convert them to a Calendar.
An application should create a Date object using a Calendar. The application is responsible for specifying the time as 00:00:00 on the desired date when using the Calendar since JDBC uses this convention. In addition when creating a Time value the application must specify a date of January 1, 1970 to the Calendar used to create the millisecond value for the Time as this is the convention specified by JDBC for time.
Above from:
http://java.sun.com/products//jdk/1.2/docs/guide/jdbc/spec2/jdbc2.0.frame10.html
I hope it can help you!

Similar Messages

  • How to set the timezone for oc4j/beeapp log

    Hi all,
    The timezone of my beehive server host is set as PST.
    But in the oc4j/beeapp log of beehive server, I found the timezone is different from my host server.
    It is inconvenient for me to trace log.
    How can I set to make the time record in log of the same timezone with my host?
    Regards,
    vivian

    Hi,
    What is the timestamp showing? Esp wrt/TZ. It is in ISO form, and should have the TZ offset as the last part of the string.
    Is it off by an hour or many (ie is it a daylight savings issue)?
    Thanks.

  • How to set the timezone?

    I'm trying to set the time zone of the browser, because the messages on my webmail client have an incorrect time...

    Please first update to Firefox 29.0.1, the version you are running is very old and out of date. [[Update Firefox to the latest version]]
    After that, there are two places your timezone might be messed up. One is in Windows itself (Firefox uses Window's time zone settings). http://windows.microsoft.com/en-us/windows/set-clock#1TC=windows-7 can help you set that.
    The other is in the settings of your webmail itself. Look in the settings after you log into your e-mail to find a timezone setting.

  • How to set the value of a data template parameter at runtime?

    I went through the document and found one line "A parameter is a variable whose value can be set at runtime.". But there is no further description or example about this feature.
    Can anyone tell how to do or show me a example?
    Thanks in advance

    Hi,
    define in the report-definition a parameter (for example p_deptno). This results in an entry in the xdo-file:
    <parameter id="p_deptno"> ....
    Define the same parameter in the Data Template ....
         <parameters>
    <parameter name="p_deptno" datatype="number"/>
    </parameters>
    and use this parameter in your Query:
    <sqlStatement name="QueryDept">
    <![CDATA[SELECT DEPTNO,DNAME,LOC FROM DEPT WHERE DEPTNO = :p_depnto]]>
    </sqlStatement>
    Regards
    Rainer

  • How to set the time interval for data obtain through labview via write measureme

    I'm need to programme to obtain data from oscilloscope. Currently my laptop able to communicate with Agilent DSO6014A oscilloscope via USB. I'm include the write measurement in mty program and save the data in .lvm file. But the time interval in the data are too small which is in micron seconds. Is there a way to modify the interval values?

    The attached file is the capture of my diagram. Thanks.
    Attachments:
    Capture.PNG ‏56 KB

  • How can I set the timezone in my application?

    I inherited a website in which the DateFormat() function is littered throughout, and plays an integral role in ensuring the application runs correctly. For instance, we have a calendar system in which employees can book lessons on certain days and at certain times. The Date and Time functions are key to this application's success.
    But we moved the website from one server to a newer, shared, one a few months back running CF10 on Windows Server 2008. (I believe the old one was running CF8 on a Windows 2000 server or something.) But what appears to be happening is that other users on this new shared box are changing the date/time based on their needs and at different times, and it is affecting our applications. I called the support staff of the hosting company who told me I had to specify the date and time via Java in my application file and that should solve the problem.
    The issue is that I really have no idea how to do this. My programming with Java is virtually null, and even my familiarity with ColdFusion is waning, as I have not seriously used it in about 9 years. I see there are a number of tutorials and demonstrations on the web for accessing date and time via Java in ColdFusion, but I don't know how to set the application to a specified timezone, (which is what I think I have to do), so that when the DateFormat() object is called, it calls the correct date. Otherwise, when employees go to book lessons, the dates are off. Their calendar will show that April might begin on a Tuesday instead of a Monday. At other times we've noticed the hour is off by a considerable amount - 4 or 5 hours, when the server itself is in a timezone only 1 hour behind us.
    Any idea how to pull something like this off?
    I figure even if I can specify the timezone in the application files I may have to overwrite every instance of DateFormat() to something customized, but I'm hoping I don't have to go that far.
    Any help is greatly appreciated.

    Question: Do you think the response from the support staff is correct? I mean, surely, I can't be the only CF user on a shared box whose other users need to modify the date and time within their applications. Even if they do it at the application level for their domain, surely it wouldn't affect mine, would it? That was what was implied by the support people, but I have a feeling they are way off, or covering for some goof-up on their end. I struggled like hell yesterday trying to get this to work and I did not get very far at all.
    I found an interesting tutorial here which does a comparison of time zones and, theoretically, this might do the trick. But if what the guy told me was nonsense then I won't bother with it. For the record, our calendar has been working fine for about a week now.

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • How to set the Default values for Info Objects in Data Selection of InfoPac

    Hi All,
    Flat file Extracion:
    How to set the Default values for Info Objects in Data Selection Tab  for Info Package
    ex: Fiscal Year Variant  Info Object having values 'K4' 'Y2' etc  in Flat file
    Initially  default value(not constant)  for this info Object value should be 'K4'  in Info Package
    If I set data selection value for this info object K4 it will retreive records with this selection only? how to handle
    Rgds,
    CV

    Hi,
    suppose as your ex. if you are having fiscalyear variant in the dataselection tab then specify K4 in the from column, again the ficalyearvariant row and click on insert duplicate row at the bottom . you will get another row . In that enter Y2 in the from column. now you can extract K4, y2 values .
    haritha

  • How to set the field SKB1-FDLEV as requestred-entry in G/L Master data?

    Hi All,
    Could anyone tell me how to set the field SKB1-FDLEV as requestred-entry in G/L Master data?
    Thanks
    Gandalf

    hi
    Go to OB26
    select Your criteria ( create, change or display)
    double click on it
    again double click on Bank/financial details
    there you will find the Planning level make it require entry
    save
    with regards
    ramanuja chary

  • How to set the default value of an item type DATE PICKER to the day of yest

    Hi
    How to set the default value of an item type DATE PICKER to the day of yesterday ?
    Thank you very much !
    Christian.

    Hi Christian,
    Have a look at this thread Re: Default the Date Picker to Today
    It covers this issue in detail.
    Regards
    Paul

  • How to set the data fields column wide at sqlplus

    Dear Sir/Madam
    I would like to know how to set the data fields column wide at sqlplus
    Thanks
    Francis

    see
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch6.htm#sthref1131
    and the FORMAT clause of the COLUMN command in
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12013.htm#BACHCABF

  • How to set the Data Synchronisation mode for ADF BC component?

    Hi All,
    How to set the Data Synchronisation mode for ADF BC component
    Thanks
    Raghavendra

    Can you clarify what you mean by the data synchronization mode?
    If you mean the Sync Mode, then in 10.1.3 you set this property by:
    1. Selecting your DataBindings.cpx file
    2. Expanding the "Data Control Usages" section in the structure window
    3. Selecting the ADFBC-based data control
    4. Setting the "syncMode" property in the property inspector.

  • T.code KO88: how to set the document date?

    Hi All,
    could anyone tell me how to set the document date in the t.code KO88?
    Thanks
    Gandalf

    Hi,
    Normally, the system define  the posting date based the date when document entered into Financial Accounting or cost accounting. Based on posting date,system will define the posting period and fiscal year.
    Posting date can be different from Entry date ( the date date entered into SAP system), where no influence from user, and it can also different from Document date. Document date is the of original document was created.
    Hope this will give you clearer overview of dates which are used in system.
    Regards,
    Irhasni

  • How to set the table input in Query template?

    Hi all.
    I need to call a Bapi_objcl_change, with import parameter and a table as an input. I have done this, in BLS. I have set the table input in the
    form of xml. In BLS, I get the output(the value gets change in SAP R3, what i have given in BLS).  But if i set the same xml structure  in
    query template, I didn't get the output. Table input parameter does not take that xml source.  How to set the table input in Query template?
    can anyone help me?
    Regards,
    Hemalatha

    Hema,
    You probably need to XML encode the data so that it will pass properly and then xmldecode() it to set the BAPI input value.
    Sam

  • How to find the table in which data from a structure sits

    Hi,
    I want to know how to find the exact table where data sitting in various structures during runtime are stored.
    For instance,in ME23N we have various tabs and data in those are held in various structures. This we can see by checking the technical setting of each field.
    I want to know in which table the data is actually stored for each field and how to find them.
    Any other means other than using "WHERE USED" option?
    Thanks
    CM

    After checking for technical field from the screen, when you reach out to structure, you can dbl click on the particular field's data element. From this data-element you can get to know in which tables it is used. Also if the data element refers to some master data field then you can check out its domain and in the domain you can refer the<b> value table</b> for that domain. This is what i will do if i am not sure about anything.
    Hope it will help a little.
    Jignesh.

Maybe you are looking for

  • Is there one tell  me the correct way to access remote SQL server

    Hi I have tried to access a remote SQL server by many ways but all failed here is my trying : String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String url= "jdbc:microsoft:sqlserver://217.52.98.102:1433"; Class.forName(driver); Connecti

  • AR Invoice - Stocks

    Dear Experts, I have Item ABC bought on 1st of Jan 2010 (qty =10). Then i bought more on 1st of Feb 2010 (Qty = 5). I have created a stock ageing report using Query generator, and i can view the current ageing 1-30 days = Qty 5 and 30-60days = Qty10

  • Externally Loaded Dynamic Text Problem

    Hi, Has anyone encountered problems loading in a % sign as part of a string? For example I'm loading the following in from a database through an asp page using sendAndLoad (this is just a snippet of the results): &AnswerEN1_1=8% &AnswerFR1_1= The var

  • How to find 'Assembly' indicator in a BOM explosion FM

    Hi experts, I need a function module to explode BOM for Materials which are having checked by Assebmly indicator. I tried fm : CS_BOM_EXPL_MAT_V2. But i didnt find a field for this indicator. Can any of you tell me how to find weather 'Assembly' indi

  • Cannot Publish to Word

    Hi, I'm new to using Captivate 3.0 and just running in the Trial mode as we are evaluating this product. The main reason we want to use Captivate is because of the ease in creating Word Documents in a custom format. However, after creating my project