时间戳转换为日期:

public void ChanggeTime(String timeStamp){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String sd = sdf.format(new Date(Long.parseLong(String.valueOf(timeStamp))));      // 时间戳转换成时间
        System.out.println("格式化结果:" + sd);
    }

 

日期转换成时间戳

 public void dateToStamp(String s) throws ParseException {
        String res;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = simpleDateFormat.parse(s);
        long ts = date.getTime();
        res = String.valueOf(ts);
        System.out.println("格式化结果:" + res);
    }

  

相关文章:

  • 2021-10-12
  • 2021-12-27
  • 2021-12-05
  • 2021-11-21
  • 2021-06-30
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-08-05
  • 2021-09-11
相关资源
相似解决方案