Convert timestamp into date format Java

Posted on 2009-04-17
Last Modified: 2012-06-21
I want to change a timestamp value into a date format (yyyy-mm-dd hh:MM:ss).
Please suggest.
Question by:parveendalal
    LVL 86

    Expert Comment


    DateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:MM:ss");
    String s = df.format(new Date(ts.getTime()));

    Open in new window

    LVL 92

    Accepted Solution

    timastamp is a subclass of Date so you can format it the same way as you would a date

    Featured Post

    Hire Top Freelancers to Complete Java Projects

    Source the talented Expert Exchange community
    for top quality work on your Java projects.

    Hire the best. Collaborate easily. Get quality work.

    Join & Write a Comment

    Suggested Solutions

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now