0

如何根据格式找到日期和时间的时间戳:

Wed Oct 31 17:40:42 IST 2012
4

2 回答 2

1

使用SimpleDateFormat解析您的日期

SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Calendar cal = Calendar.getInstance();
System.out.println(parserSDF.format(cal.getTime()));

它将打印为Wed Oct 31 18:28:55 IST 2012

于 2012-10-31T12:56:32.840 回答
0

使用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
于 2012-10-31T12:58:17.473 回答