Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5988771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:00:22+00:00 2026-05-22T23:00:22+00:00

I have written the following function in Java. This function returns current timestamp by

  • 0

I have written the following function in Java. This function returns current timestamp by executing a query. The function code is as follows :

private  String getTimeStamp(){
    String timeStamp=null;      
    try{
        String strQuery="select current_timestamp";
        PreparedStatement pmtQuery=con.prepareStatement(strQuery);
        ResultSet rsQuery=pmtQuery.executeQuery();
        rsQuery.next();
        timeStamp=rsQuery.getString(1);
        JOptionPane.showMessageDialog(null, "Value of timeStamp : "+timeStamp);
    }catch(SQLException e){
        System.out.println("SQL Exception in the getTimeStamp()");
    }       
    return timeStamp;
} 

When I use this function on windows It gives proper out put and works fine.
Ex.

If execute above function in widows it gives timestamp like ex. 2011-06-01 17:05:03

but when I execute this function in Debina linux it gives timestamp as
2011-06-01 17:05:03.0

It appends .0 to timestamp

Please guide me in this problem

1.why such different output comes on different system?

2.How to avoid this problem?

3.How to solve this problem?

I am using following configurations

windows

windows 7, Mysql database, Java 6

Linux

Debian linux, Mysql Database, Java 6

Thank You!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:00:23+00:00Added an answer on May 22, 2026 at 11:00 pm

    Use this

    SELECT DATE_FORMAT(CURDATE(), '%d/%m/%Y %hh%mm%ss')
    

    Note:

    I wonder why you are querying to get the currentDate

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(All of the following is to be written in Java) I have to build
I often have to debug Java code which was written so that there is
I have written the following function to calculate a check digit in R. verhoeffCheck
I have written the following code using node.js and riak-js . I have a
I have the following function that was written by someone else, however I am
If you look at http://www.danfarrellwright.com/screwsline/front_end/product.php?product_id=104 I have written the following function to add the
I have the following function written to randomly pick a file from a directory.
I have the following segment of code that someone else has written, and that
I have written the following simple test in trying to learn Castle Windsor's Fluent
I have written something that uses the following includes: #include <math.h> #include <time.h> #include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.