您的位置:首页 > 游戏 > 游戏 > 高端网站设计品牌_自己做网站怎么推广_写手接单平台_河南公司网站建设

高端网站设计品牌_自己做网站怎么推广_写手接单平台_河南公司网站建设

2025/3/10 17:02:55 来源:https://blog.csdn.net/bestwinner/article/details/144802814  浏览:    关键词:高端网站设计品牌_自己做网站怎么推广_写手接单平台_河南公司网站建设
高端网站设计品牌_自己做网站怎么推广_写手接单平台_河南公司网站建设

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import java.time.temporal.ChronoUnit;

public class Test {
    public static void main(String[] args) throws ParseException {
        String startTime = "2024-11-28";
        String endTime = "2024-12-02";
        List<String> dateList = Lists.newArrayList();
        dateList.add(startTime);
        long days = betweenDays(startTime, endTime);
        for (int i = 0; i < days; i++) {
            Date tempDate = MyDateUtil.dateAdd(MyDateUtil.strToDate(startTime), 1);
            startTime = MyDateUtil.dateToStr(tempDate);
            dateList.add(startTime);
        }
        System.out.println(dateList.toString());
    }
}

//打印输出:[2024-11-28, 2024-11-29, 2024-11-30, 2024-12-01, 2024-12-02]

public static long betweenDays(String date1, String date2) {LocalDate startDate = LocalDate.parse(date1);LocalDate endDate = LocalDate.parse(date2);return ChronoUnit.DAYS.between(startDate, endDate);
}
public static Date dateAdd(Date startTime, Integer dd) {if (startTime == null) {startTime = MyDateUtil.getNowTime();}Calendar cal = Calendar.getInstance();cal.setTime(startTime);if (dd != null && !dd.equals(0)) {cal.add(Calendar.DATE, dd);}return new Date(cal.getTime().getTime());
}
public static Date strToDate(String strDate) throws ParseException {return MyDateUtil.strToDate(MyDateUtil.Y4MD, strDate);
}
public static final String Y4MD = "yyyy-MM-dd";
public static Date strToDate(String aMask, String strDate) throws ParseException {Date date = null;if (StringUtil.isEmpty(strDate)) {return date;}if (StringUtil.isEmpty(aMask)) {aMask = MyDateUtil.YMDHMS;}SimpleDateFormat df = new SimpleDateFormat(aMask);date = df.parse(strDate);return (date);
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com