通过LocalDate获取某一年份的12个月的月初和月末

    //获取指定年份的12个月的月初和月末
    LocalDate oneStart = LocalDate.parse(year+"-01-01", ISO_DATE);
    LocalDate oneEnd = oneStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate twoStart = LocalDate.parse(year+"-02-01", ISO_DATE);
    LocalDate twoEnd = twoStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate threeStart = LocalDate.parse(year+"-03-01", ISO_DATE);
    LocalDate threeEnd = threeStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate fourStart = LocalDate.parse(year+"-04-01", ISO_DATE);
    LocalDate fourEnd = fourStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate fiveStart = LocalDate.parse(year+"-05-01", ISO_DATE);
    LocalDate fiveEnd = fiveStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate sixStart = LocalDate.parse(year+"-06-01", ISO_DATE);
    LocalDate sixEnd = sixStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate sevenStart = LocalDate.parse(year+"-07-01", ISO_DATE);
    LocalDate sevenEnd = sevenStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate eightStart = LocalDate.parse(year+"-08-01", ISO_DATE);
    LocalDate eightEnd = eightStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate nineStart = LocalDate.parse(year+"-09-01", ISO_DATE);
    LocalDate nineEnd = nineStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate tenStart = LocalDate.parse(year+"-10-01", ISO_DATE);
    LocalDate tenEnd = tenStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate elevenStart = LocalDate.parse(year+"-11-01", ISO_DATE);
    LocalDate elevenEnd = elevenStart.with(TemporalAdjusters.lastDayOfMonth());
    LocalDate twelveStart = LocalDate.parse(year+"-12-01", ISO_DATE);
    LocalDate twelveEnd = twelveStart.with(TemporalAdjusters.lastDayOfMonth());

你可能感兴趣的:(java)