?
Solved

time stamp in Excel

Posted on 2002-06-03
2
Medium Priority
?
158 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 200 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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