public String getMonday(String date) { if (date == null || date.equals("")) { System.out.println("date is null or empty"); return "0000-00-00 00:00:00"; } SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd")
1 根据当前日期获得所在周的日期区间(周一和周日日期) public String getTimeInterval(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); // 判断要计算的日期是否是周日,如果是则减一天计算周六的,否则会出问题,计算到下一周去了 int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// 获得当前日期是一个星期的第几天 if (1 == day
Learn From:http://blog.csdn.net/sunhuwh/article/details/39161323 public class CalendarTest { public static void main(String[] args) { // 获取当前年份.月份.日期 Calendar cale = null; cale = Calendar.getInstance(); int year = cale.get(Calendar.YEAR); int month =
最近在写接口的时候老遇见从mysql中获取近几天数据的需求,获取日期这块不是很熟,网上看了很多但是代码量都太大,还是问了下别人,写了三行代码就解决了,不多说 贴代码了 下面是我获取近十天,每天的日期: List<String> dayList = new ArrayList<String>(); long start=1559356078000l; long end=1560133678000l; do { dayList.add(new DateTime(start).toStr
public static void main(String[] args) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String dateFirst="2017-05-01"; String dateSecond="2017-05-25"; try{ Date st
java 获取日期的几天前,几个月前和几年前. package bys.utils; import java.util.Date; /** * Created by toutou on 2015/3/23. */ public class DateHelper { public static final long ONE_MINUTE = 60000L; public static final long ONE_HOUR = 3600000L; public static final long
原文地址:http://bdcwl.blog.163.com/blog/static/765222652009104171521/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = sdf.parse("2009-11-04");//String-->Date String sdate = sdf.format(date );// Data-->String Ti