// Gets the day number of a date public int getDate(Date d) { Calendar ca = Calendar.getInstance();
ca.setTime(d); int days = ca.get(Calendar.DATE); return days; } // Before a given date / after n day
// n=-1 Indicates the previous day ,n=1 The next day public Date getDateForDayNum(Date date, int n) { Calendar
ca = Calendar.getInstance(); ca.setTime(date); ca.add(Calendar.DAY_OF_MONTH,
n); Date d = ca.getTime(); return d; } // Before a given date / after n month // n=-1 Indicates the previous month ,n=1 Indicates the next month
public Date getDateForMonthNum(Date date, int n) { Calendar ca =
Calendar.getInstance(); ca.setTime(date); ca.add(Calendar.MONTH, n); Date d =
ca.getTime(); return d; } // Front / Month after , Front / Date of the day after public Date getDateForMonthNum(Date
date, int Month,int day) { Calendar ca = Calendar.getInstance();
ca.setTime(date); ca.add(Calendar.MONTH, Month); ca.add(Calendar.DAY_OF_MONTH,
day); Date d = ca.getTime(); return d; } // Before a given date / after n year // n=-1 Indicates the previous year ,n=1 Indicates the following year
public Date getDateForYearNum(Date date, int n) { Calendar ca =
Calendar.getInstance(); ca.setTime(date); ca.add(Calendar.YEAR, n); Date d =
ca.getTime(); return d; } // Before a given date / after n hour // n=-1 Represents the previous hour ,n=1 It means the next hour public Date
getDateForHourNum(Date date, int n) { Calendar ca = Calendar.getInstance();
ca.setTime(date); ca.add(Calendar.HOUR, n); Date d = ca.getTime(); return d; }
// The last day of a month in a year public Date getLastDay(Date date) { Calendar ca =
Calendar.getInstance(); ca.setTime(date); ca.roll(Calendar.MONTH, 1);// Roll back one month
ca.set(Calendar.DATE, 0); Date time = ca.getTime(); return time; } // How many days are there in a month and year
public int getDateNumForDate(Date date) { Calendar ca = Calendar.getInstance();
ca.setTime(date); ca.roll(Calendar.MONTH, 1); ca.set(Calendar.DATE, 0); return
ca.get(Calendar.DATE); } // What day of the week is a month or a year ( Return on Sunday 0, Monday to Saturday 1-6) public int getWeek(Date
date) { Calendar ca = Calendar.getInstance(); int week =
ca.get(Calendar.DAY_OF_WEEK) - 1;// set up return week; }
 

Technology
©2019-2020 Toolsou All rights reserved,
VUE+Canvas Achieve desktop Pinball brick elimination games C/C++ Memory model 2019PHP Interview questions ( Continuously updated )PHPspringboot2 Separation of front and rear platforms ,token Put in header Pit for verification Vue SpringBoot conduct Excel download element-ui Step on pit record 45 The 12-year-old programmer was turned down , Is the workplace wrong ?Python Web frame Pandas Fundamentals of statistical analysis _ data processing (DataFrame Common operations )Java Misunderstanding —— Method overloading is a manifestation of polymorphism ?