Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-24
3
Medium Priority
?
1,212 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 300 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 92

Expert Comment

by:objects
ID: 10914047
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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 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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

885 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