sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Java工具类方法 时间字符串转成时间戳 2022-10-08 10:47:08 yyyy-MM-dd HH:mm:ss 返回时间戳 1665290918

  1. public long gettimeStemp(String time, String format) {
  2. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  3. if (!"".equals(format)) {
  4. simpleDateFormat = new SimpleDateFormat(format);
  5. }
  6. long timeStemp = 0;
  7. try {
  8. Date date = simpleDateFormat.parse(time);
  9. timeStemp = date.getTime();
  10. } catch (ParseException e) {
  11. e.printStackTrace();
  12. }
  13. return timeStemp;
  14. }

https://blog.csdn.net/YINLUXIA/article/details/122638948
posted on 2022-10-09 12:50  sunny123456  阅读(1862)  评论(0编辑  收藏  举报