alexhere

由于业务中有一项需求需要在新员工三个月快转正的时候发邮件,所以写个小例子看看效果

时间在实体类中是long型,所以想的是先转出date,用calender计算加75天之后再转成String显示

 

 pasting

public static void main(String args[]) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
long longTime = new Date().getTime();
System.out.println("long为:" + longTime);
System.out.println("Long转换成日期:");
System.out.println("longToDate:" + new SimpleDateFormat("yyyy-MM-dd ").format(new Date(longTime)));
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(longTime));
calendar.add(Calendar.DAY_OF_MONTH, +75);
System.out.println("75天后:" + sdf.format(calendar.getTime().getTime()));
}
测试结果如下 

long为:1529133715787

Long转换成日期:

longToDate:2018-06-16

75天后:2018-08-30

分类:

技术点:

相关文章:

  • 2021-10-19
  • 2021-05-17
  • 2022-12-23
  • 2021-10-19
  • 2021-09-22
  • 2022-01-07
  • 2021-12-15
猜你喜欢
  • 2021-11-24
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
相关资源
相似解决方案