Java工具类方法 时间字符串转成时间戳 2022-10-08 10:47:08 yyyy-MM-dd HH:mm:ss 返回时间戳 1665290918
- public long gettimeStemp(String time, String format) {
-
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- if (!"".equals(format)) {
- simpleDateFormat = new SimpleDateFormat(format);
- }
-
- long timeStemp = 0;
- try {
-
- Date date = simpleDateFormat.parse(time);
-
- timeStemp = date.getTime();
-
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return timeStemp;
- }
https://blog.csdn.net/YINLUXIA/article/details/122638948
标签:10,Java,mm,08,yyyy,HH,dd
From: https://www.cnblogs.com/sunny3158/p/16771760.html