java - Convert month name to Date range -
i need convert monthname + year valid date range. needs work leap years etc.
examples
getdaterange("feb",2015)
should find range 2015-02-01 -- 2015-02-28
while
getdaterange("feb",2016)
should find range 2016-02-01 -- 2016-02-29
in java 8, can using temporaladjusters,
localdate firstdate= date.with(temporaladjusters.firstdayofmonth()); localdate lastdate= date.with(temporaladjusters.lastdayofmonth());
if have year , month, better use yearmonth. yearmonth can length of month.
yearmonth ym= yearmonth.of(2015, month.february); int monthlen= ym.lengthofmonth();
Comments
Post a Comment