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 7946267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:06:06+00:00 2026-06-04T01:06:06+00:00

I wrote a function that got a Timestamp (year, month, day, hour, min and

  • 0

I wrote a function that got a Timestamp (year, month, day, hour, min and sec) as a parameter.

I just now find that instead of getting a Timestamp type, I got a long type – after the next stpes:

The constructor is:

protected SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

and then:

long qu = dateFormat.parse("24.12.2011 18:54:23").getTime();

I try to find how to convert the qu, back to SimpleDateFormat and then to Timestamp, or directly: from long to Timestamp (But where long was created after these two steps).

eariler, I ask how to convert long to Timestamp. The answer was given is correct, but Im afraid that this is not the case when I convert it from SimpleDateFormat to long (the function doesn’t work after the change).

Thanks.

  • 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-06-04T01:06:07+00:00Added an answer on June 4, 2026 at 1:06 am

    This works for me:

    public class Test {
      public static void main(String... args) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        try {
          long qu = dateFormat.parse("24/12/2011 18:54:23").getTime();
          Timestamp ts = new Timestamp(qu);
          System.out.println(ts);
        } catch (ParseException e) {
          e.printStackTrace();
        }
      }
    }
    

    Outputs: 2011-12-24 18:54:23.0

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

Sidebar

Related Questions

I've got a function I wrote quite some time ago that works fine, but
I need to import a function that I wrote in C++, and is now
Alright, so I've got a function I wrote that should allow me to post
I've got a Jquery function that I wrote which blacks out the screen after
I've got a Jquery function that I wrote which blacks out the screen after
Here's a simplified version of a function I wrote just now: int foobar(char *
I wrote a function that scans a tab delimited file of baseball stats. public
I was just doing some stuff and wrote this program. I got the following
I wrote a certain function that I'd like all my Django models to have.
I just wrote the following C++ function to programmatically determine how much RAM a

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.