0

How can I find the timestamp of date and time both as per the format:

Wed Oct 31 17:40:42 IST 2012
shkschneider
  • 17,833
  • 13
  • 59
  • 112
CodingDecoding
  • 433
  • 2
  • 9
  • 20

2 Answers2

1

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

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
0

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
shkschneider
  • 17,833
  • 13
  • 59
  • 112