简体   繁体   中英

How to get the month start and end date for the ISO year using Joda time library in Java

For a specific month and year,I want to get the month start and end date for the ISO year using Joda time library in Java. Like say for example, I have month as March and year 2014, SO I want to know the starting and end date for the month March in ISO year.

Apart from joda-time library, Is there also any other way to get the same thing.

Maybe this could help:

DateTime dt = new DateTime().withYear(2014).withMonthOfYear(3);
DateTime start = dt.withDayOfMonth(1).withTimeAtStartOfDay();
DateTime end = start.plusMonths(1).minusMillis(1);
LocalDate monthBegin = new LocalDate().withDayOfMonth(1);
LocalDate monthEnd = new LocalDate().plusMonths(1).withDayOfMonth(1).minusDays(1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM