I want this format 6 Dec 2012 12:10
String time = "2012-12-08 13:39:57 +0000 ";
DateFormat sdf = new SimpleDateFormat("hh:mm:ss");
Date date = sdf.parse(time);
System.out.println("Time: " + date);
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.
You need to first parse your date string (Use
DateFormat#parse()method) to get theDateobject using a format that matches the format ofdate string.And then format that Date object (Use
DateFormat#format()method) using the required format inSimpleDateFormatto get string.Output: –
Zin the first format is for RFC 822 TimeZone to match+0000in your date string. SeeSimpleDateFormatfor various other options to be used in your date format.