How can I find the timestamp of date and time both as per the format:
Wed Oct 31 17:40:42 IST 2012
How can I find the timestamp of date and time both as per the format:
Wed Oct 31 17:40:42 IST 2012
use the SimpleDateFormat
to parse your date
SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Calendar cal = Calendar.getInstance();
System.out.println(parserSDF.format(cal.getTime()));
It will print as Wed Oct 31 18:28:55 IST 2012
Use SimpleDateFormat
:
String str_date = "Wed Oct 31 18:28:55 IST 2012";
// Here is your date as string
DateFormat formatter = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Date date = (Date) formatter.parse(str_date);
Timestamp timeStampDate = new Timestamp(date.getTime());
// Here is your date as timestamp