Solved

How do I cast an java Integer to a java TimeStamp?

Posted on 2004-04-24
3
1,190 Views
Last Modified: 2012-06-27
Hi Experts,


I have an Java  Integer which is in the format 20040424 How do I  CAST it to a  java Timestamp?


I appreciate that it may need conversion to a another class prior to a conversion to Timestamp.

Thanks

azsat.
0
Comment
Question by:azsat
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 10909532
int i = 20040424;
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date d = sdf.parse(Integer.toString(i));
Timestamp ts = new Timestamp(d.getTime());
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10910283
0
 
LVL 92

Expert Comment

by:objects
ID: 10914047
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

706 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

17 Experts available now in Live!

Get 1:1 Help Now