Results 1 to 6 of 6

Thread: Problem in retrieving timestamp

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Problem in retrieving timestamp

    Hello,
    I record in my database the date as a timestamp, but in a BIGINT column.
    So my code is like this:
    Code:
    //--- Retrieve the date as tmstamp
    Date tm = new Date();
    Datebdd = tm.getTime();
    Then I try a query on it, but here is the problem. The problem is when I want to retrieve and display above what is recorded in the database.
    I did this but it does not work:
    Code:
    //--- Declaration date formatting
    dtfrm dtfrm = dateFormatter.getDateTimeInstance(dtfrm.LONG, dtfrm.SHORT, Local.FRANCE);
     
    //--- Recovery after the date the application
    String = dt dateFormatter.format(resultsNewCD.getLong("datebdd"));
    I think I have a problem in retrieving the timestamp.

  2. #2
    Join Date
    Nov 2009
    Posts
    347

    Re: Problem in retrieving timestamp

    Hello,
    Try with SimpleDateFormat already to verify that you got good value:
    Code:
    Date dt = new Date(resultsNewCD.getLong("dtbdd"));
    SimpleDateFormat dtfrm = new SimpleDateFormat("dd / MM / yyyy");
    System.out.System.out.println(dtfrm.format(dt));
    Looking at the javadoc, you see that you can build the date from a long, the constructor Date () without setting gives you the current date. Beware if you're not familiar with dates in Java, the calculations are rather through a Calendar.

  3. #3
    Join Date
    Dec 2009
    Posts
    211

    Re: Problem in retrieving timestamp

    Hello,
    Actually it does not want to build the date from a long, I am convinced that this is possible but it makes me an error
    Code:
    Symbol not resolved
    location: class java.text.DateFormat
    And here is the line in the code
    Code:
    Date dttm = dateFormatter.format(resultsNewCD.getLong("datebdd"));
    Yet I have included the class java.text.SimpleDateFormat java.text.DateFormat and so I do not see here ... I'm going back into the javadoc hoping to find.

  4. #4
    Join Date
    Nov 2009
    Posts
    359

    Re: Problem in retrieving timestamp

    Hello,
    I would like to add something in here. Method size () does not long, but still you you can use it. Rather I would suggest you the builder Date method.
    Code:
    Date dt = new Date(resultsNewCD.getLong("datebdd"));
    Just have a look at the above method. I think this will make your program more practical. If you need any more help regarding this then please do post back and we will try to solve your query.

  5. #5
    Join Date
    Nov 2009
    Posts
    518

    Re: Problem in retrieving timestamp

    Hello,
    Code:
    Date dt = new Date(resultsNewCD.getLong("datebdd"));
    This is cool, but you can use the following method also. This will make your code more better than earlier.
    Code:
    dateFormatter.format (new Date (resultsNewCD.getLong ( "dtbdd)));
    I am not say that the method shown above is wrong or it will not be effective. I am just asking you to use this method and test your code and see how the method works.
    Last edited by GlassFish; 12-02-2010 at 01:57 AM.

  6. #6
    Join Date
    Dec 2009
    Posts
    211

    Re: Problem in retrieving timestamp

    Hello,
    Yes, I am sorry about that I forgot to call the constructor. I will correct the problem in my code. Do not now how I missed that. In any case thank you for your quick response. If I have any more queries regarding this then I will post back till then I will try some more programs in java, so that I can get more experience in coding in java.

Similar Threads

  1. Timestamp in Voice Mail.
    By Rufta in forum Portable Devices
    Replies: 3
    Last Post: 27-12-2010, 08:06 PM
  2. Error:"Problem retrieving printer information" in Access 2003
    By Jacques25 in forum Windows Software
    Replies: 5
    Last Post: 18-03-2010, 01:57 AM
  3. Problem in retrieving string with Regex
    By Aaliya Seth in forum Software Development
    Replies: 5
    Last Post: 11-02-2010, 05:53 AM
  4. What is Timestamp in SQL?
    By Shekhar12 in forum Software Development
    Replies: 4
    Last Post: 30-11-2009, 10:02 AM
  5. C# timestamp datatype
    By Mehraj in forum Software Development
    Replies: 3
    Last Post: 04-08-2009, 06:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,010,518.73260 seconds with 16 queries