}

//获取当天的结束时间

public static Date getDayEnd() {

Calendar cal = new GregorianCalendar();

cal.set(Calendar.HOUR_OF_DAY, 23);

cal.set(Calendar.MINUTE, 59);

cal.set(Calendar.SECOND, 59);

return cal.getTime();

}

//获取昨天的开始时间

public static Date getBeginDayOfYesterday() {

Calendar cal = new GregorianCalendar();

cal.setTime(getDayBegin());

cal.add(Calendar.DAY_OF_MONTH, -1);

return cal.getTime();

}

//获取昨天的结束时间

public static Date getEndDayOfYesterDay() {

Calendar cal = new GregorianCalendar();

cal.setTime(getDayEnd());

cal.add(Calendar.DAY_OF_MONTH, -1);

return cal.getTime();

}

//获取明天的开始时间

public static Date getBeginDayOfTomorrow() {

Calendar cal = new GregorianCalendar();

cal.setTime(getDayBegin());

cal.add(Calendar.DAY_OF_MONTH, 1);

return cal.getTime();

}

//获取明天的结束时间

public static Date getEndDayOfTomorrow() {

Calendar cal = new GregorianCalendar();

cal.setTime(getDayEnd());

cal.add(Calendar.DAY_OF_MONTH, 1);

return cal.getTime();

}

//获取本周的开始时间

@SuppressWarnings(“unused”)

public static Date getBeginDayOfWeek() {

Date date = new Date();

if (date == null) {

return null;

}

Calendar cal = Calendar.getInstance();

cal.setTime(date);

int dayofweek = cal.get(Calendar.DAY_OF_WEEK);

if (dayofweek == 1) {

dayofweek += 7;

}

cal.add(Calendar.DATE, 2 - dayofweek);

return getDayStartTime(cal.getTime());

}

//获取本周的结束时间

public static Date getEndDayOfWeek() {

Calendar cal = Calendar.getInstance();

cal.setTime(getBeginDayOfWeek());

cal.add(Calendar.DAY_OF_WEEK, 6);

Date weekEndSta = cal.getTime();

return getDayEndTime(weekEndSta);

}

//获取上周的开始时间

@SuppressWarnings(“unused”)

public static Date getBeginDayOfLastWeek() {

Date date = new Date();

if (date == null) {

return null;

}

Calendar cal = Calendar.getInstance();

cal.setTime(date);

int dayofweek = cal.get(Calendar.DAY_OF_WEEK);

if (dayofweek == 1) {

dayofweek += 7;

}

cal.add(Calendar.DATE, 2 - dayofweek - 7);

return getDayStartTime(cal.getTime());

}

//获取上周的结束时间

public static Date getEndDayOfLastWeek() {

Calendar cal = Calendar.getInstance();

cal.setTime(getBeginDayOfLastWeek());

cal.add(Calendar.DAY_OF_WEEK, 6);

Date weekEndSta = cal.getTime();

return getDayEndTime(weekEndSta);

}

//获取本月的开始时间

public static Date getBeginDayOfMonth() {

Calendar calendar = Calendar.getInstance();

calendar.set(getNowYear(), getNowMonth() - 1, 1);

return getDayStartTime(calendar.getTime());

}

//获取本月的结束时间

public static Date getEndDayOfMonth() {

Calendar calendar = Calendar.getInstance();

calendar.set(getNowYear(), getNowMonth() - 1, 1);

int day = calendar.getActualMaximum(5);

calendar.set(getNowYear(), getNowMonth() - 1, day);

return getDayEndTime(calendar.getTime());

}

//获取上月的开始时间

public static Date getBeginDayOfLastMonth() {

Calendar calendar = Calendar.getInstance();

calendar.set(getNowYear(), getNowMonth() - 2, 1);

return getDayStartTime(calendar.getTime());

}

//获取上月的结束时间

public static Date getEndDayOfLastMonth() {

Calendar calendar = Calendar.getInstance();

calendar.set(getNowYear(), getNowMonth() - 2, 1);

int day = calendar.getActualMaximum(5);

calendar.set(getNowYear(), getNowMonth() - 2, day);

return getDayEndTime(calendar.getTime());

}

//获取本年的开始时间

public static Date getBeginDayOfYear() {

Calendar cal = Calendar.getInstance();

cal.set(Calendar.YEAR, getNowYear());

// cal.set

cal.set(Calendar.MONTH, Calendar.JANUARY);

cal.set(Calendar.DATE, 1);

return getDayStartTime(cal.getTime());

}

//获取本年的结束时间

public static Date getEndDayOfYear() {

Calendar cal = Calendar.getInstance();

cal.set(Calendar.YEAR, getNowYear());

cal.set(Calendar.MONTH, Calendar.DECEMBER);

cal.set(Calendar.DATE, 31);

return getDayEndTime(cal.getTime());

}

//获取某个日期的开始时间

public static Timestamp getDayStartTime(Date d) {

Calendar calendar = Calendar.getInstance();

if (null != d) {

calendar.setTime(d);

}

calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);

calendar.set(Calendar.MILLISECOND, 0);

return new Timestamp(calendar.getTimeInMillis());

}

//获取某个日期的结束时间

public static Timestamp getDayEndTime(Date d) {

Calendar calendar = Calendar.getInstance();

if (null != d) {

calendar.setTime(d);

}

calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);

calendar.set(Calendar.MILLISECOND, 999);

return new Timestamp(calendar.getTimeInMillis());

}

//获取今年是哪一年

public static Integer getNowYear() {

Date date = new Date();

GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();

gc.setTime(date);

return Integer.valueOf(gc.get(1));

}

//获取本月是哪一月

public static int getNowMonth() {

Date date = new Date();

GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();

gc.setTime(date);

return gc.get(2) + 1;

}

/**

  • 将字符串的月份开始天数和结束天数解析成日期格式

  • @param format

  • @return

*/

public static List parseGetMonth(String format) {

List dateList = new ArrayList<>();

String[] split = format.split(“-”);

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy.MM.dd”);

try {

Date startDate = sdf.parse(split[0]);

Date endDate = sdf.parse(split[1]);

dateList.add(startDate);

dateList.add(endDate);

} catch (ParseException e) {

e.printStackTrace();

}

return dateList;

}

/**

  • 获取任意天数的月份开始天数和结束天数

*/

public static String getMonth(Date date) {

StringBuffer sb = new StringBuffer();

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:SS”);

String format = sdf.format(date);

String[] split = format.split(“-”);

int month = Integer.parseInt(split[1]);

int year = Integer.parseInt(split[0]);

for (int i = 1; i <= 12; i++) {

if (month == 4 || month == 6 || month == 9 || month == 11) {

sb.append(JSON.toJSONString(year));

sb.append(“.”);

sb.append(JSON.toJSONString(month));

sb.append(“.”);

sb.append(“01-”);

sb.append(JSON.toJSONString(year));

sb.append(“.”);

sb.append(JSON.toJSONString(month));

sb.append(“.”);

sb.append(“30”);

break;

} else if (month == 2) {

sb.append(JSON.toJSONString(year));

sb.append(“.”);

sb.append(JSON.toJSONString(month));

sb.append(“.”);

sb.append(“01-”);

sb.append(JSON.toJSONString(year));

sb.append(“.”);

sb.append(JSON.toJSONString(month));

sb.append(“.”);

sb.append(“28”);

break;

} else {

sb.append(JSON.toJSONString(year));

sb.append(“.”);

sb.append(JSON.toJSONString(month));

sb.append(“.”);

sb.append(“01-”);

sb.append(JSON.toJSONString(year));

sb.append(“.”);

sb.append(JSON.toJSONString(month));

sb.append(“.”);

sb.append(“31”);

break;

}

}

return sb.toString();

}

//两个日期相减得到的天数

public static int getDiffDays(Date beginDate, Date endDate) {

if (beginDate == null || endDate == null) {

throw new IllegalArgumentException(“getDiffDays param is null!”);

}

long diff = (endDate.getTime() - beginDate.getTime())

/ (1000 * 60 * 60 * 24);

int days = new Long(diff).intValue();

return days;

}

//两个日期相减得到的毫秒数

public static long dateDiff(Date beginDate, Date endDate) {

long date1ms = beginDate.getTime();

long date2ms = endDate.getTime();

return date2ms - date1ms;

}

//获取两个日期中的最大日期

public static Date max(Date beginDate, Date endDate) {

if (beginDate == null) {

return endDate;

}

if (endDate == null) {

return beginDate;

}

if (beginDate.after(endDate)) {

return beginDate;

}

return endDate;

}

//获取两个日期中的最小日期

public static Date min(Date beginDate, Date endDate) {

if (beginDate == null) {

return endDate;

}

if (endDate == null) {

return beginDate;

}

if (beginDate.after(endDate)) {

return endDate;

}

return beginDate;

}

//返回某月该季度的第一个月

public static Date getFirstSeasonDate(Date date) {

final int[] SEASON = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};

Calendar cal = Calendar.getInstance();

cal.setTime(date);

int sean = SEASON[cal.get(Calendar.MONTH)];

cal.set(Calendar.MONTH, sean * 3 - 3);

return cal.getTime();

}

//返回某个日期下几天的日期

public static Date getNextDay(Date date, int i) {

Calendar cal = new GregorianCalendar();

cal.setTime(date);

cal.set(Calendar.DATE, cal.get(Calendar.DATE) + i);

return cal.getTime();

}

//返回某个日期前几天的日期

public static Date getFrontDay(Date date, int i) {

Calendar cal = new GregorianCalendar();

cal.setTime(date);

cal.set(Calendar.DATE, cal.get(Calendar.DATE) - i);

return cal.getTime();

}

//获取某年某月到某年某月按天的切片日期集合(间隔天数的集合)

@SuppressWarnings({“rawtypes”, “unchecked”})

public static List getTimeList(int beginYear, int beginMonth, int endYear,

int endMonth, int k) {

List list = new ArrayList();

if (beginYear == endYear) {

for (int j = beginMonth; j <= endMonth; j++) {

list.add(getTimeList(beginYear, j, k));

}

} else {

{

for (int j = beginMonth; j < 12; j++) {

list.add(getTimeList(beginYear, j, k));

}

for (int i = beginYear + 1; i < endYear; i++) {

for (int j = 0; j < 12; j++) {

list.add(getTimeList(i, j, k));

}

}

for (int j = 0; j <= endMonth; j++) {

list.add(getTimeList(endYear, j, k));

}

}

}

return list;

}

//获取某年某月按天切片日期集合(某个月间隔多少天的日期集合)

@SuppressWarnings({“unchecked”, “rawtypes”})

public static List getTimeList(int beginYear, int beginMonth, int k) {

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

总结

虽然我个人也经常自嘲,十年之后要去成为外卖专员,但实际上依靠自身的努力,是能够减少三十五岁之后的焦虑的,毕竟好的架构师并不多。

架构师,是我们大部分技术人的职业目标,一名好的架构师来源于机遇(公司)、个人努力(吃得苦、肯钻研)、天分(真的热爱)的三者协作的结果,实践+机遇+努力才能助你成为优秀的架构师。

如果你也想成为一名好的架构师,那或许这份Java成长笔记你需要阅读阅读,希望能够对你的职业发展有所帮助。

image

《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门即可获取!
JesJpR-1712476020798)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

总结

虽然我个人也经常自嘲,十年之后要去成为外卖专员,但实际上依靠自身的努力,是能够减少三十五岁之后的焦虑的,毕竟好的架构师并不多。

架构师,是我们大部分技术人的职业目标,一名好的架构师来源于机遇(公司)、个人努力(吃得苦、肯钻研)、天分(真的热爱)的三者协作的结果,实践+机遇+努力才能助你成为优秀的架构师。

如果你也想成为一名好的架构师,那或许这份Java成长笔记你需要阅读阅读,希望能够对你的职业发展有所帮助。

[外链图片转存中…(img-PvZOTVm1-1712476020799)]

《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》点击传送门即可获取!

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐