Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1214
  • Last Modified:

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

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
azsat
Asked:
azsat
  • 2
1 Solution
 
objectsCommented:
int i = 20040424;
DateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date d = sdf.parse(Integer.toString(i));
Timestamp ts = new Timestamp(d.getTime());
0
 
objectsCommented:
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now