I have an int variable with following. How can I convert it to Date object and vice versa.
int inputDate=20121220;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Convert the value to a
Stringand useSimpleDateFormatto parse it to aDateobject:The converse is similar, but instead of using
parse, useformat, and convert from the resultingStringto anInteger:An alternative is to use
substringand manually parse theStringrepresentation of yourInteger, though I strongly advise you against this: