标签:span offset logs date() utils pre col tin time
package cn.lay.utils; import java.util.Calendar; import java.util.Date; /** * 时间处理 * @author lay */ public class DateUtils { public static Date addDays(Date date, int offset){ Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.DATE, offset); return calendar.getTime(); } } public static void main(String[] args) { Date now = new Date(); System.out.println("今天:" + now); System.out.println("昨天:" + DateUtils.addDays(now, -1)); System.out.println("明天:" + DateUtils.addDays(now, +1)); }
标签:span offset logs date() utils pre col tin time
原文地址:http://www.cnblogs.com/lay2017/p/7567722.html