Java time to DB2 timestamp conversion

I want to convert current time to following format "2008-01-12 11:46:55.945000". I tried but I an not able to do. Could you pelase hlep me out or is there any easy way to do
          Calendar calendar = Calendar.getInstance();
          //2008-01-12 11:46:55.945000
          int year = calendar.get(Calendar.YEAR);
          int date = calendar.get(Calendar.DATE);
          int month = calendar.get(Calendar.MONTH);
          int hour = calendar.get(Calendar.HOUR);
          int minite = calendar.get(Calendar.MINUTE);
          int second = calendar.get(Calendar.SECOND);
          int millisecond = calendar.get(Calendar.MILLISECOND);
          String timestamp = year+"-"+date+"-"+month+" "+hour+":"+minite+":"+second+"."+millisecond;

have you try like:
java.sql.Timestamp creationdate = new java.sql.Timestamp(new Date().getTime());
prepStmt.setTimestamp(1, creationdate);or format the date as "yyyy-MM-dd HH:mm:ss" like string by using SimpleDateFormat
and use
java.sql.Timestamp creationdate =
               java.sql.Timestamp.valueOf(creationDate);

Similar Messages

  • Time String to Timestamp Conversion Problem

    Hi,
    I attempted to convert time string to timestamp but I failed. What is the wrong with it? I need a timestamp to create waveforms.
    Egemen
    Solved!
    Go to Solution.
    Attachments:
    Time String to Timestamp.png ‏18 KB

    You are right Gogineni, when I got the error, I was using %S in the format string for Format Date/Time String function and %3u in the format string for Scan From String.
    I found the solution in this thread - use %S%3u in both places.
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • DB2 timestamp to oracle timestamp conversion

    Does any one know how to convert Db2 timestamp into oracle timestamp.
    From DB2 we are getting timestamp in this format (2000-03-06-16.02.19.074474) (26 bytes).
    I want to insert this into oracle thru owb into oracle table with column type timestamp.
    Does anyone know the procedure for this type of conversion
    Thanks in advance..

    Hi,
    Try a migration tool at www.ispirer.com/chyfo.html
    It provides you the fastest, the easiest and the most powerful way to migrate
    DB2 database into Oracle.
    It works in conjunction with Oracle SQL Loader. The tool creates text files (moving of LOBs are fully supported), generates
    CREATE TABLE scripts for Oracle and control files for SQL Loader.
    The tool has a lot of other features.
    Best regards, Dmitry.
    null

  • Timestamp conversion problem.

    I work in the development of a LabVIEW program that communicates with a
    server (written in Java). All acquired data is sent via TCP and the
    server can read everything (waveforms and other information). However,
    there is a problem in timestamp conversion. We don't know how to
    convert the milliseconds correctly. The timestamp is inside a waveform,
    so we cannot convert it to formatted string.
    Example:
    Original timestamp:
    13:37:19,639
    11/10/2005
    String generated with "Flatten to String":
    0000 0000 BF71 9ABF A3D7 0800 0000 0000
    Converted value (Java server):
    13:37:19,000
    11/10/2005
    Does anyone know the algorithm to obtain the milliseconds from this value: "A3D7 0800"?
    Thanks for attention.
    My regards,
    Vinicius Falseth
    Solved!
    Go to Solution.

    There is a faster way.  You can extract the timestamp from the waveform using Get Waveform Components. 
    At that point, you can convert it to whatever you want.  Attached
    is a VI which shows a simple conversion to milliseconds, losing a lot
    of resolution (128 bit timestamp goes to 52 bit double) and a more
    complex conversion showing the internal structure of the timestamp (it
    is a 128 bit fixed point number with the decimal in the middle). 
    You can modify the second conversion to do such things as throw away
    the integer portion to get higher resolution on the fraction.  Or
    you could just save to Java using a four-integer structure.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    timestamp.llb ‏48 KB

  • How to estimate the time needed for unicode conversion

    Experts:
    I am going to perform an upgrade from 46C (non-unicode) to ECC6/EHP4.
    In the action plan , it's hard to estimate the time needed for unicode conversion.
    We do not have a sandbox to benchmark that time.
    Could you please help share your experience here?
    Thanks!!

    Hi,
    usually it is very hard to estimate a proper time.
    There are some hints to get a rough feeling (SAP note 857081 and [SMP link|http://service.sap.com/~form/sapnet?_SHORTKEY=01100035870000380759&_OBJECT=011000358700001279022010E] ).
    However please note that SAP highly recommends to do a Sandbox conversion - otherwise there is a high risk that the PRD conversion will take (much) longer than expected.
    Best regards,
    Nils Buerckel

  • Java Timer problem

    hi,
    i am finding some problem using java timer.
    I have a server program that regularly needs to save its data. i want to do it using java Timer.
    i got the following sample code as an example. it works perfectly but how can i send new data each time to save?
    import java.util.Timer;
    import java.util.TimerTask;
    import Core.General;
    public class test_timer {
    public static void main(final String args[]) {
    final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new ttask(), 3000, 3000);
    class ttask extends TimerTask
    public void run() {
    System.out.println("hello ");
    As an example i would like to send current time to the timer task and print it. how is it possible?
    regards
    tom

    For the current time you can just go ahead and do the following call:
    System.currentTimeMillis();
    This will get you the current time in milleseconds.
    When timer is called, get the crrent time and print it.
    Hope this helps.
    hi,
    i am finding some problem using java timer.
    I have a server program that regularly needs to save
    its data. i want to do it using java Timer.
    i got the following sample code as an example. it
    works perfectly but how can i send new data each time
    to save?
    import java.util.Timer;
    import java.util.TimerTask;
    import Core.General;
    public class test_timer {
    public static void main(final String args[]) {
    final Timer timer = new Timer();
    timer.scheduleAtFixedRate(new ttask(), 3000,
    000, 3000);
    class ttask extends TimerTask
    public void run() {
    System.out.println("hello ");
    As an example i would like to send current time to the
    timer task and print it. how is it possible?
    regards
    tom

  • Java Add-in or unicode conversion first?

    Hi all.
    I have just performed a BW 3.5 (NW 6.40) to BI 7.0 (NW 7.0) NON-unicode upgrade. The next two things we want to do are unicode conversion and java add-in installation.
    I am wondering which of these actions should come first; Java add-in or unicode conversion?
    Any thought on this?
    Regards,
    Thomas

    It´s pretty straighforward using the sapinst.
    Make sure you patch up the AddIn to the same patchlevel your ABAP is running on (means,if you BIND support package 13 to the upgrade, upgrade the Java engine to SP13 as well after installation).
    Personal opinion:
    If we have the choice we don´t use the Java Addin but install the Java part on a separate system. The Addin adds more complexity and dependency to the system. On top of that it makes memory configuration and predictability of sizing very difficult.
    This is - however - my personal opinion, this may or may not be true for your environment.
    Markus

  • Java 8: Pb with new java.time api

    Hello,
    I'm trying to use the new java.time api that comes with Java 8 (I already know joda-time).
    I'm using the latest build B124.
    I've a String "01/08/2012_00:00:01", I know that the time ref. is UTC, and I want to convert it to an 'Instant';
    I tried:
    DateTimeFormatter FORMAT_DT = DateTimeFormatter.ofPattern("dd/MM/yyyy_HH:mm:ss").withZone(ZoneOffset.UTC);
    Instant instant = Instant.from(FORMAT_DT.parse("01/08/2012_00:00:01"));
    But it fails with following error:
    java.time.DateTimeException: Unable to obtain Instant from TemporalAccessor: {},ISO resolved to 2012-08-01T00:00:01 of type java.time.format.Parsed
         at java.time.Instant.from(Unknown Source)
    I don't understand what's wrong with my code, and I can't figure out how I should proceed to convert the String to an Instant ...
    Any suggestion welcome,
    Best regards,
    Bernard.

    Originally you stated this:
    I don't understand what's wrong with my code,
    So naturally we focused on how to "understand what's wrong' with your code.
    You will never learn to troubleshoot problems if you just throw your hands up in the air and ask for help just because a complex series of steps doesn't complete successfully. 
    Break the process into its individual steps and check the results of each step to identify which step is FIRST producing an error.
    When a complex or multi-step process has an error you start checking the individual steps of the process to see how far it gets successfully.
    I would expect that converting a String to an Instant should be a basic/simple need, so it should be possible to do it in two lines of code; for the time being, the only way I found is to use a LocalDateTime intermediate variable, which seems quite verbose, and I'm wondering if someone knows a better way to do it, and would be willing to share it here.
    Just a technical distinction: your latest example using a LocalDateTime intermediate variable CAN be done in one line of code by just using dot-notation to avoid creating an explicit intermediate variable. But that variable will still be created implicitly behind the scenes.
    Converting a String to an Instant might be considered a basic/simple need but the set of functionality related to dealing with times, dates, calendars, etc is extremely complex. It makes much more sense to develop the requisite functionality in modules.
    Especially when introducing new functionality such as the 'Instant' class are related package elements introduced in 1.8. That functionality builds on what came before and parsers already existing that know how to deal with all of the possible String variants and formatting options and so on.
    Since that work CAN BE done on-the-fly using dot notation and anonymous implicit intermediate classes there isn't much need to reinvent that functionality in the new classes. If certain uses become standard new methods can always be added (e.g. to the Instant class) that will 'appear' to do things in one step.
    And, being an early adopter release, you can always file a 'bug' or enhancement request from the 1.8 download page. That page has links for 'Report Bugs' and 'Feedback forum' that you can use.
    In this current forum no one can give you an 'official' answer as to why something was implemented a particular way and/or whether that implementation is a 'bug' or was designed to work that way. Only Oracle can do that.

  • Using java.time.LocalDate class

    Hello,
    I am using the latest JDK8 build b87 and JDeveloper 11.1.2.1. In the editor, the code insight does not show the java.time.LocalDate class. When I use the LocalDate class, it is highlighted in red. However, I can compile and run the application fine. Other classes in the java.time package, for example, the Clock class is fine. I can use classes from the java.time subpackages fine. How can I fix this issue?
    Thanks
    Kishori

    JDeveloper does not support JDK 8 as indicated by the certification matrix.
    http://www.oracle.com/technetwork/developer-tools/jdev/index-091111.html
    java.time.LocalDate being a new class, code insight does not support the class.

  • Help to create Materialized View that has timestamp conversion

    I need help creating materialized view with timestamp conversion between GMT to LocalTime.
    Feel free to make any comments.
    Thanks in advance.
    jon joaquino;)

    Here is one way.
    1. Alter the table hist_table and add a new column pdt_timestamp.
    2. Update the new column using the function 'new_time'
    For example,
    Update hist_table
    set pdt_timestamp = new_time(gmt_timestamp,'GMT','PDT');
    3. create a materialized view log on the table 'hist_table' using the syntax
    create materialized view log on hist_table
    with primary key, rowid, sequence;
    4. create a materialized view now using the syntax:
    (You have to specify your own storage numbers and tablespace name)
    create materialized view mview_hist_table
    pctfree 0 tablespace mymview
    storage (initial 16k next 16k pctincrease 0)
    build immediate
    refresh fast on commit
    as select uid,gmt_timestamp,pdt_timestamp
    from hist_table;
    Please test on your test instance before doing it on production. I have tested this on Oracle 10g for Windows 2000. I assumed that column 'uid' is the primary key on the table. I hope this helps.
    **********************************************************

  • Look-up java time zone based on location?

    I have a test app where I can assign a java timezone and return time info - However, I don't see a way to look-up a java time zone based on location (combination of city/province/state/country).
    Is this possible?

    Has any one found a way to lookup a timezone based on a city/region in the world? So one could be able to type any city and state/province and country combination and get the corresponding timezone for that region. Is there a place where one can buy this data?
    Thank you

  • OCCI Fractional time insertion using Timestamp class

    Hello,
    On linux with oracle 10g, I modified the demo app occidml to insert a Timestamp into a table. I print the factional time from the timestamp after it is created to verify that indeed it is the correct value. However, when I query the database using SQL, I find that the fractional time component didn't get inserted. Any ideas on how to resolve this would be highly appreciated.
    Here is the code snippet for inserting the timestamp..
    string sqlStmt = "INSERT INTO author_ag VALUES (:x, :y)";
    stmt=conn->createStatement (sqlStmt);
    try{
    Timestamp ts(env, 2008,9,10,11,12,13, c1);
    uint h,m,s,f;
    ts.getTime(h, m, s, f);
    stmt->setTimestamp (1, ts);
    stmt->setString (2, c2);
    stmt->executeUpdate ();
    cout << "insert - Success" << c1 << " " << f << endl;
    }catch(SQLException ex)
    cout<<"Exception thrown for insertBind"<<endl;
    cout<<"Error number: "<< ex.getErrorCode() << endl;
    cout<<ex.getMessage() << endl;
    I see the following output:
    insert - Success222 222
    The database table is as follows:
    SQL> desc author_ag
    Name Null? Type
    TS TIMESTAMP(3)
    AUTHOR_NAME VARCHAR2(25)

    My mistake. Didn't realize the fractional time had to be specified as NanoSeconds.

  • Tomcat Restart and Java Timer

    I have used Java Timer class to schedule a report to be generated during midnight. It works fine if i do not stop Tomcat, but when i stop and restart Tomcat server the Timer job seems to be lost and it doesn't run during the midnight. Any ideas how to resolve this issue? I thought timer's would be persistent...Thanks.

    So it should be web-based....is there a way??1. Never shut down the web server.
    2. [Deleted]
    3. Create your own report server (standalone application) and create a web-based application to interact with the report server (standalone application) and send it the query.
    In the third option, you can start and stop the web server all you want. The report server will continue running. The report server will only fail to respond to requests if the machine (node) is turned off or if there is a bug.

  • Java Time conversion

    Hi
    I know this must a simple thing to do in Java but I can't seem to find it.
    I need to convert UTC time in millisec into GMT regular time. i.e.
    1155000000000 should be converted to Tue Aug 8 01:20:00:000 GMT 2006
    Thnx

    Crossposted and answered:
    http://forum.java.sun.com/thread.jspa?threadID=759645&messageID=4337407#4337407
    Don't waste your time on this.

  • Time stamp to number conversion

    Hi All,
    I notice in Labview 7.0 the 'Get Date/Time to Seconds' and 'Seconds to Date/Time' now output a Time Stamp rather than actual seconds.
    There is a 'To Time Stamp" standard vi in the conversion pallet that converts a number (seconds) to a time stamp but I really need to convert from a Time Stamp to real seconds.
    Does anyone have a vi that might do this or is there something already in LabVIEW 7.0 I have overlooked?
    Many Thanks in Advance for your help.
    Sammy Mason

    You are going to have to post an example where the conversion does not work.
    Message Edited by Dennis Knutson on 05-05-2007 05:34 AM
    Attachments:
    TimeStamp to Dbl.PNG ‏2 KB

Maybe you are looking for

  • Problem ordering prints

    Hello, I tried to order prints from iphoto and my order was cancelled 3 times. I sent an email to Apple & received the following response: Thank you for contacting iPhoto Customer Support. Unfortunately we were not able to complete your order because

  • Vendor master cannot copy to PO (sometimes)

    hi, When convering PR to PO in (MD04), Invoicing Party not found and need manual input.  The same issue found if input vendor code first during PO entry (ME23N).  But sometimes do not have this problem even using same vendor pls advice thanks

  • Support for Panasonic Lumix DMC-FZ8

    Is Apple planning to support RAW for the Panasonic Lumix DMC-FZ8 in Aperture? Adobe Photoshop and Lightroom provide support for this camera. Any ideas?

  • Family Sharing, Ask to buy and iTunes cards

    my son got a iTunes Gift card for christmas.  Is it possible to add the gift card to his Apple account, but still have the Family Sharing Ask to Buy feature work?  Or will he get to make purchases without the Ask to Buy feature working?

  • Z1 Screen repair

    Hi, talk about premium design... my z1 was in my pocket and the glass broke some how! how much would it cost to get fixed? and i heard it wont be water proof? is this true? there must b a way?!! Thanks