Solved

time stamp in Excel

Posted on 2002-06-03
2
155 Views
Last Modified: 2010-03-31
My servlet queries a table to retrieve information including a column with timestamps. I then display the information in an Excel spreadsheet but it displays only the time. I can format the column in Excel to display the date and time in the column but was wondering if there was a way to do this through the code. Thanks!
0
Comment
Question by:g125047
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
udaykumar22 earned 50 total points
ID: 7053108
hi g125047,

Use the SimpleDateFormat class in java.text package.

===========================================================

When you retrieve your resultset :-

SimpleDateFormat SDF
     = new SimpleDateFormat ("yyyy.MM.dd hh:mm:ss");
 Date dateTime = rsltSet.getTimestamp();
 String dateString = SDF.format(dateTime);

===========================================================

This would give you the date and time in string format and you can then use this for storing into the excell sheet.

===========================================================

Regards,
Uday.

0
 

Author Comment

by:g125047
ID: 7054412
Thanks so much. Just a note that I had to use the Timestamp class instead of the Date class for the code to work.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

707 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