Get week of month with Joda-Time

前端 未结 4 466
半阙折子戏
半阙折子戏 2021-01-12 20:00

Is it possible to parse a date and extract the week of month using Joda-Time. I know it is possible to do it for the week of year but I cannot find how/if it is possible to

4条回答
  •  醉话见心
    2021-01-12 20:25

    For the case you don't like calculations so much:

        DateTime date = new DateTime();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date.toDate());
        int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH);
    

提交回复
热议问题