Solved

time stamp in Excel

Posted on 2002-06-03
2
146 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 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

18 Experts available now in Live!

Get 1:1 Help Now