DB timestamp value with JVM TimeZone

Hi all,
If we have database timestamp "*1970-01-01T16:00:00*", no matter what Time Zone the jvm is running with, we get the java.sql.Timestamp object representing the time "1970-01-01T16:00:00" locally(Shang Hai, Las Vegas, London...). So, the UTC time will be different as well.
I need to do some conversion work to make database timestamp "1970-01-01T16:00:00" as UTC time. Although it will be different in jvms with different time zones, they all mean the same time(UTC time, same million seconds from UTC Time 1970-01-01T00:00:00.000) and will be consistent.
For how to do the conversion, do you have any suggestion?

Seems like an odd request.
1. If your database does NOT specify a timezone then the jdbc connection string would have a way to do that explicitly.
2. If you database DOES specify a timezone then you would need to write SQL (not java) that returned a unspecified timezone value, probably a string, which you would use to create a java timestamp (for example via SimpleDateFormat).
The above or course presumes that you understand that the jdbc has perfectly acceptable ways of getting correct timestamps from databases and that displaying a timestamp value has nothing to do with that.

Similar Messages

  • Jdbc timestamp error on getting timezone

    Hello
    I changed my application from J2EE standalone container 9.0.4 to the new OAS 10.1.0.2.
    Now I have a problem with timestamp CMP-Attributes.
    When I set a timestamp attribut and get it back I have the following exception. The JDBC driver seems to convert the timestamp variable with a sun util for timezones.
    I allready set the timezone to real value on the database and with -Duser.timezone Options for the VM.
    The Exception is:
    java.lang.IllegalArgumentException
         at sun.util.calendar.ZoneInfo.getOffset(ZoneInfo.java:322)
         at oracle.jdbc.driver.DateTimeCommonAccessor.zoneOffset(DateTimeCommonAccessor.java:370)
         at oracle.jdbc.driver.DateTimeCommonAccessor.getMillis(DateTimeCommonAccessor.java:411)
         at oracle.jdbc.driver.TimestampAccessor.getTimestamp(TimestampAccessor.java:153)
         at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetImpl.java:750)
         at com.evermind.sql.ResultSetBCELProxy.getTimestamp(ResultSetBCELProxy.java:297)
         at FaelleLocal_EntityBeanWrapper30.loadStateCorePKNonPartial(FaelleLocal_EntityBeanWrapper30.java:44476)
         at EbenenLocal_FaelleLocal_ORCollection172.getObjects(EbenenLocal_FaelleLocal_ORCollection172.java:93)
         at com.evermind.server.ejb.ORCollection.contains(ORCollection.java:273)
         at com.evermind.server.ejb.ORCollection.add(ORCollection.java:228)
         at com.evermind.server.ejb.ORCollection.add(ORCollection.java:355)
         at FaelleEJB_PersistenceManager31.__core__setebene(FaelleEJB_PersistenceManager31.java:1083)
         at FaelleEJB_PersistenceManager31.setEbene(FaelleEJB_PersistenceManager31.java:1109)
         at FaelleLocal_EntityBeanWrapper30.setEbene(FaelleLocal_EntityBeanWrapper30.java:11182)
         at com.rehabnet.rehabcycle.server.util.TOFactory.setFallTO(TOFactory.java:693)
         at com.rehabnet.rehabcycle.server.impl.ResourceManagerSessionEJB.setFall(ResourceManagerSessionEJB.java:1411)
         at ...
    Thanks for your help.
    best
    chrue

    Hello
    Thanks for your help.
    I solved the problem.
    We changed the column type from date to timestamp.
    While doing this oracle produces illegal timestamp values with negativ milliseconds. When the bean reads the data he convert the time to the java time with the timezone. The IllegalArgumentException was throwing because of the negativ millisecond part.
    best
    chrue.

  • Printing report that has a parameter with multiple values crashes jvm

    I am using BOE XI 4.0 as an unmanaged RAS.
    I am able to preview a report that has a string discrete parameter that can have multiple values.  If I give it a single value.  It previews fine.  If I give it an empty string it prints all values which is fine.  If I give it two discrete values, it displays just those two.
    However, if I try printing the report to a printer:
    1 parameter value - prints fine.
    2 parameter values - crashes jvm
    empty string parameter value - crashes jvm
    I would appreciate some direction on how to do this.  It works in crystal reports for eclipse.
    The test jsp I am using is based off of the samples.  The print test jsp is the same as the preview test with the exception of the following code differences.:
    preview report.jsp code
    // Create a Viewer object
    CrystalReportViewer viewer = new CrystalReportViewer();
    // Set the report source for the  viewer to the ReportClientDocument's report source
    viewer.setReportSource(clientDoc.getReportSource());
    // Process the http request to view the report
    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
    // Dispose of the viewer object
    viewer.dispose();
    print report jsp code
      PrintReportOptions printOptions = new PrintReportOptions();
      printOptions.setPrinterName("DELL");
      try {
          clientDoc.getPrintOutputController().printReport(printOptions);
      } catch (ReportSDKException ex1) {
          System.out.println("Message - " + ex1.getLocalizedMessage());
      } catch (Exception ex2) {
          System.out.println("Message - " + ex2.getLocalizedMessage());
      clientDoc.close();

    I am using BOE XI 4.0 as an unmanaged RAS.
    I am able to preview a report that has a string discrete parameter that can have multiple values.  If I give it a single value.  It previews fine.  If I give it an empty string it prints all values which is fine.  If I give it two discrete values, it displays just those two.
    However, if I try printing the report to a printer:
    1 parameter value - prints fine.
    2 parameter values - crashes jvm
    empty string parameter value - crashes jvm
    I would appreciate some direction on how to do this.  It works in crystal reports for eclipse.
    The test jsp I am using is based off of the samples.  The print test jsp is the same as the preview test with the exception of the following code differences.:
    preview report.jsp code
    // Create a Viewer object
    CrystalReportViewer viewer = new CrystalReportViewer();
    // Set the report source for the  viewer to the ReportClientDocument's report source
    viewer.setReportSource(clientDoc.getReportSource());
    // Process the http request to view the report
    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
    // Dispose of the viewer object
    viewer.dispose();
    print report jsp code
      PrintReportOptions printOptions = new PrintReportOptions();
      printOptions.setPrinterName("DELL");
      try {
          clientDoc.getPrintOutputController().printReport(printOptions);
      } catch (ReportSDKException ex1) {
          System.out.println("Message - " + ex1.getLocalizedMessage());
      } catch (Exception ex2) {
          System.out.println("Message - " + ex2.getLocalizedMessage());
      clientDoc.close();

  • Java.sql.Timestamp creation with value -4712.01.01 (oracle min timestamp)

    How can I create ajava.sql.Timestamp with the value -4712.01.01?
    Trying Timestamp timestamp = new Timestamp( -210863523208000l );leads to the date 4713-02-08 00:06:32.0.
    Or what is the minimal java.sql.timestamp value in Java?
    Edited by: bejq on 17.03.2009 08:56

    bejq wrote:
    Thanks for your quick answer.
    Yes it is 1st January 4712 BC.
    Timestamp timestamp = new Timestamp( -4712, 1, 1, 0, 0, 0, 000 );//deprecated Method
    System.out.println( timestamp ); // returns 2813-02-01 00:00:00.0
    System.out.println( timestamp.getTime() );// returns -150904688400000Thats not what I want.You have lost me then. Unless of course you want to use SimpleDateFormat with an appropriate TZ to parse the date to a java.util.Date and then construct a java.sql.Timestamp from the java.util.Date using the java.util.Date#getTime() method to construct the java.sql.Timestamp .
    Edited by: sabre150 on Mar 17, 2009 10:41 AM

  • Reading Timestamp value into an SSIS variable

    I need to read the last timestamp value (MAX(TimeStampValue)) from a table, store it in a variable in SSIS and using the variable, perform a comparison against another table and load delta records. 
    The string data type is not playing well with the timestamp data type and things get even more complicated if I try to store the timestamp value as a varchar in a table.
    Is there any variable data types in SSIS that will store the timestamp value easier than a string?

    It could be due to the time stamp value being incompatible with the date time functions which you need to fix.
    So to make it conform manipulate on its value to get the proper format.
    PS: Varchar WILL swallow any text, please be more specific, think how others would be reproducing YOUR issue.
    Arthur My Blog

  • SQL*Loader and timestamp values

    I'm loading timestamp values (among other data) from a text file into Oracle using SQL*Loader.
    The data I load is formatted like the following:
    2008/11/13 23:55:21.366
    2008/11/13 23:55:22.782
    2008/11/13 23:55:25.879
    Hence my control file look like this:
    TSTAMP TIMESTAMP "YYYY/MM/DD HH24:MI:SS.FF",
    The timestamp data in the input file are in UTC, however I load into a column that is of type "TIMESTAMP(3)", i.e. in server time. This is on purpose. I do not want the data to be in UTC when I look at them.
    Therefore after the load I have to manually do
    UPDATE mytable
    SET tstamp = tstamp + (tstamp - sys_extract_utc(tstamp));
    This update-after-loading actually takes quite some time due to the amount of records. I would like to avoid it and instead do it as part of the load. Is this possible somehow?
    I'm on Oracle 10.2.
    Thanks.

    Hi
    What about setting a special Time Zone in your database?
    You have two options when setting which time zone the database belongs to. You can either qualify it as a displacement from GMT/UTC in the format of 'hh:mm' or you can specify it as a name that has an entry in the V$TIMEZONE table.
    select tzname,tzabbrev from V$TIMEZONE_NAMES;
    select DBTIMEZONE from dual;
    ALTER database SET TIME_ZONE = 'Denmark/Copenhagen';
    select SESSIONTIMEZONE from dual;
    select CURRENT_TIMESTAMP from dual;
    See that link
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref319
    Edited by: Hub on Dec 7, 2008 3:58 PM

  • Difference in timestamp values

    Hi,
    We have a project for like to like migration for R12 to R16, but ther are differences in the timestamp values calulated between the two enviornments
    The R12 Production server is 5 hrs head of R16 production server.
    i have applied the following formula to both the production report:
    Timestampdiff(SQL_TSI_MINUTE,TIMESTAMP '2009-07-06 12:12:12',TIMESTAMP '2009-08-07 11:11:11')
    the results are in Minutes:
    R12:44578
    R16:46019
    Is this because of the difference in server timing? or R16 has a feature to calulate the difference without considering the timezones, daylight saving etc which the R12 lacks, because when i checked which of the 2 difference is correct, the R16 differnce seems to be correct.
    Please share your thoughts on this as it is affecting large no .of reports.
    Many Thanks

    /* Formatted on 2012/04/12 15:56 (Formatter Plus v4.8.8) */
    DECLARE
       v_time1       date;
       v_time2       date;
       v_time_diff   number;
    BEGIN
       SELECT To_Date(TO_CHAR (wss_gdp_time, 'DD-MON-YYYY HH12:MI:SS'),'DD-MON-YYYY HH12:MI:SS')
         INTO v_time1
         FROM tab1
        WHERE wss_gdp_time = (SELECT MAX (wss_gdp_time)
                                FROM tab1) AND ROWNUM <= 1;
       SELECT to_Date(TO_CHAR (wss_gdp_time, 'DD-MON-YYYY HH12:MI:SS'),'DD-MON-YYYY HH12:MI:SS')
         INTO v_time2
         FROM tab1
        WHERE wss_gdp_time = (SELECT MAX (wss_gdp_time)
                                FROM tab1
                               WHERE wss_gdp_time < (SELECT MAX (wss_gdp_time)
                                                       FROM tab1))
          AND ROWNUM <= 1;
       SELECT ((v_Time1-v_time2) * 1440)
         INTO v_time_diff
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_time1 || ' ' || v_time2 || ' ' || v_time_diff);
       IF v_time_diff > '10'
       THEN
          DBMS_OUTPUT.put_line ('ALERT');
       ELSE
          DBMS_OUTPUT.put_line ('No ALERT');
       END IF;
    END;
    /

  • Using Timestamp Object with day light saving time

    Hi,
    I am getting problem while using timestamp object with daylight saving time.
    I am in 'Europe/London' time zone.
    The summer time for this year starts on 30 March(last sunday) at 0200 hours.
    For hour 30/03/2003 01:00, I created a date object using SimpleDateFormat and then created the timestamp object using the longvalue got from dateObject.getTime();
    On printing the timestampObject.toString() it displays
    30/03/2003 00:00 BST.
    It seems that timestamp object uses the system timezone and I want it to be in GMT.
    Could you please tell me how can I get GMT time from timestamp object.
    When creating timestamp object from date

    To translate Date/Timestamp objects in a controlled way use DateFormat objects. When you create a DataFormat object you can specify a Locale object which stipulates timezone information.

  • To get previous day timestamp of a timestamp value in java

    Hi,
    I have a timestamp variable, say settledTimeStamp which is passed as a runtime argument to a query. I should also send another timestamp variable say previousTimeStamp whose value should be previous day timestamp, ie for settledTimeStamp.
    For example,
    Todays date= May 9th 2008.
    say settledTimeStamp to May 7th 2008.
    I should get the timestamp value for previous day to SettleDate i.e May 6th, 2008.
    I am showing this as an example because I tried with Calendar options too but it takes current timestamp and gives previous days timestamp which is not the same as I required. Like it returns May 8th as my previousTimeStamp if I work with Calendar options....
    Can anyone help me on this?

    An object of the Calendar class represents a specific point in time. The fields, such as DAY_OF_MONTH, allow you to access meaningful parts of that specific point in time and use them. Calendar.DAY_OF_MONTH is a field, and it doesn't represent the "current day" or any particular point in time at all. It's used to ask a particular Calendar object what its DAY_OF_MONTH is.
    import java.util.Calendar;
    public class Test {
         public static void main(String[] args) {
              Calendar cal = Calendar.getInstance();
              cal.setTimeInMillis(99999999999L);
              int year = cal.get(Calendar.YEAR); //cal, what is your YEAR?
              System.out.println(year);
              int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); //cal, what is your DAY_OF_WEEK?
              System.out.println(dayOfWeek);
              boolean inApril = Calendar.APRIL == cal.get(Calendar.MONTH); //cal, are you in the month of APRIL?
              System.out.println(inApril );
              System.out.println(cal); //cal, tell me all about yourself
    }Really, the documentation can do a better job explaining it than I can. Read it. And there are numerous Calendar and Date tutorials all over the internet. Date processing in java is not the easiest thing, so it can take a bit of getting used to, but you will have to read the documentation and write code yourself to understand it.
    Oh, and you mark your question as answered and then dispense duke stars to posts you felt were helpful. I don't think people here really care much about them.

  • JVM timezone property in websphere

    If I set the user.timezone system property for an application deployed in Websphere appserver, does it affect any other apps using the same JVM? Anyone, please let me know. I set this system property using Websphere Admin console. The steps are below.
    Start the administrative console.
    In the topology tree, expand Servers and click Application Servers.
    Click the name of the application server for which you want to set the time zone.
    On the application server page, click Process Definition.
    On the Process Definition page, click Java Virtual Machine.
    On the Java Virtual Machine page, click Custom Properties.
    On the Custom Properties page, click New.
    Specify user.timezone in the Name field and timezone in the Value field, where timezone is the supported value for your time zone.
    Click Apply.
    Save the configuration
    Thanks in advance!!

    > can fail if the user does not have the rights to access the JVMs parameter.
    Not sure what that means but I am pretty sure it is false.  Perhaps it was in reference to a customer security manager.
    f) You could find and fix the JVM code itself. Easier of course if it is a java code bug rather than a binary bug.  If java code only then you could use a bootclass loader option to put your fix in place when the VM starts.
    But I would probably go for a.

  • Adding Hours To Timestamp Values In A Materialized View

    Is it possible to add x hours to a TIMESTAMP column in a materialized view?
    (I'm using Oracle 10g.)

    In what context?
    DOM@DOM11gR1>CREATE MATERIALIZED VIEW mv1
      2  AS
      3  SELECT SYSTIMESTAMP ts1,SYSTIMESTAMP + 6/24 ts2, SYSTIMESTAMP + INTERVAL '6' HOUR ts3
      4  FROM DUAL;
    Materialized view created.
    DOM@DOM11gR1>desc mv1
    Name                                                              Null?    Type
    TS1                                                                        TIMESTAMP(6) WITH TIME ZONE
    TS2                                                                        DATE
    TS3                                                                        TIMESTAMP(9) WITH TIME ZONE
    DOM@DOM11gR1>select ts1, to_char(ts2,'DD/MM/YYYY HH24:MI:SS') ts2, ts3 from mv1
      2  /
    TS1                                      TS2                 TS3
    15-SEP-09 17.50.44.681271 +01:00         15/09/2009 23:50:44 15-SEP-09 23.50.44.681271000 +01:00
    DOM@DOM11gR1>

  • Displaying Variables values with Text also in the selection screen of repor

    hai
    I have one InfoObject ZPLANT .When i try to excute the report then im getting only the Values of ZPLANT(not Text of those values) .Like below
    ZPLANT :-
    101 -
    (im getting like this)
    101 London Plant ( i want like this ,when i try to excute the report).
    Please tell me how to do .
    rizwan

    Yes kamaljeet ,
    When we press F4 , then we will gwt some values .
    I want those values with description also ..
    Pls tell me how can i get those F4 values with text in the selection screen of report .
    i ll assing the points
    rizwan

  • If a  class method exporting a value with the generic type 'data'.

    Then how can I get the information?
    For exmple.
    cl_my_clss->get_value( exporting ev_data = .... ) .
    ev_data is a type of data.
    I can not use DATA : lv_mine type data. because generic data should be used in formal parameter, however , if I use a field symbol, how to assign value with out knowing the data type?
    Best regards,

    Hi Blake,
    As per my understanding,
    You are getting the data type from the database table....
    You want to use the same data type....
    Lets say for example:
    You have a db table x with field y having data type Z.
    What you do is that, while declaring the data type for the attribute in the method use the reference as table_name-field_name(x-y).
    Or....
    use ANY. This will give you a chance to map any field type to this method....
    Note: Using ANY will limit the syntax that you can use within the method......
    Regards,
    Kunjal

  • How to pack .class or .jar with jvm into an exe file?

    In fact, .class or .jar files are middle layer files who need JVM to explain and run them. Sometimes it's unconvenient. Why not provide some tools to pack .class or .jar with jvm into exe file?

    because java should be able to run on any OS. That is why SUN doesn't provide such tool. There are other company's who does provide such tool. Like JBuilder enterprise

  • Regarding Sun Java System Application Server Issue with JVM

    Regarding Sun Java System Application Server Issue with JVM
    Hi
    I have installed SJSAS9.1 on solaris system. I m trying to deploy war file which i compiled in windows enviorment by jdk1.5.0_05. Every time i got the following error :
    type Exception report
    message
    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP
    PWC6199: Generated servlet error:
    [javac] javac: invalid target release: 1.5
    [javac] Usage: javac
    [javac] where possible options include:
    [javac] -g Generate all debugging info
    [javac] -g:none Generate no debugging info
    [javac] -g:{lines,vars,source} Generate only some debugging info
    [javac] -nowarn Generate no warnings
    [javac] -verbose Output messages about what the compiler is doing
    [javac] -deprecation Output source locations where deprecated APIs are used
    [javac] -classpath Specify where to find user class files
    [javac] -sourcepath Specify where to find input source files
    [javac] -bootclasspath Override location of bootstrap class files
    [javac] -extdirs Override location of installed extensions
    [javac] -d Specify where to place generated class files
    [javac] -encoding Specify character encoding used by source files
    [javac] -source Provide source compatibility with specified release
    [javac] -target Generate class files for specific VM version
    [javac] -help Print a synopsis of standard options
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.
    I have cheked jvm version on both system the only difference is :
    Solaris points to jdk 1.5.0_09
    Windows point to jdk1.5.0_05
    Even i tried to run blank jsp also but again i got the same error.
    Can any help me to sort out the problem or give me any idea so i can do something by my own.
    Thanks in Advance
    Gagan

    Do you have ANT installed and available?
    Thanks,
    Kedar

Maybe you are looking for