Solved

time stamp in Excel

Posted on 2002-06-03
2
153 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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
custom annotations 9 42
spring jars download 1 35
eclipse buid path vs tomcat lib path 10 34
Desingning Refactoring existing code 2 26
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

839 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