How to get the specified date range in java8
This article will explain in detail how to get a specified date in java8, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
/ * get a list of specified types according to the time period * [@ param] (https://my.oschina.net/u/2303379) start * [@ param] (https://my.oschina.net/u/2303379) end * [@ param] (https://my.oschina.net/u/2303379) unit days: 0 week: January: 2 quarters: 3 half a year: 4 years: 5 * [@ return] (https://my.oschina) Net / uplink 556800) Day: 2019-07-11 week: 2019-52 month: 2019-07 quarter: 2019-4 half year: 2019-2 year: 2019 * / public static List getPeriod (LocalDate start LocalDate end,int unit) {if (start.compareTo (end) > 0) {throw new DateTimeException ("start cannot be greater than the end") } List list = new ArrayList (); switch (unit) {case 0: getDays (start,end,list); break; case 1: getWeeks (start,end,list); break; case 2: getMonths (start,end,list); break Case 3: getQuarters (start,end,list); break; case 4: getHalfYears (start,end,list); break; case 5: getYears (start,end,list); break; default: break;} return list } / / get day list private static void getDays (LocalDate start, LocalDate end, List list) {while (start.compareTo (end))