时间戳处理工具
- 输入格式:yyyy-MM-dd HH:mm:ss
- 输出格式:时间戳字符串
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
* 时间戳处理工具
*
* @author volitation
*
*/
public class TimestampUtil {
/**
* 获取时间戳字符串
*
* @param time
* @return
*/
public static String getStringTimestamp(String time) {
String timestamp = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Long longTime = sdf.parse(time).getTime();
timestamp = Long.toString(longTime);
} catch (ParseException e) {
e.printStackTrace();
}
return timestamp;
}
}