乔达时间:最近一周和一个月 [英] Joda time : Most recent week and month

查看:52
本文介绍了乔达时间:最近一周和一个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取给定日期的最近完整周和最近完整月的开始/结束日期的最佳方法是什么.

What would be the best way to get the start/end dates of most recent complete week and most recent complete month given the date.

即给定今天的日期,如何找出刚刚完成的一周,与月份相同.

I.E given the todays date, how to find out the week that just completed, same for month.

推荐答案

我找到了解决方案

    LocalDate today = new LocalDate()

    LocalDate lastWeek = today.minusWeeks(1)
    start= lastWeek .dayOfWeek().withMinimumValue().minusDays(1)
    end = lastWeek.dayOfWeek().withMaximumValue().minusDays(1)

    LocalDate lastMonth = today.minusMonths(1)
    timeStart = lastMonth.dayOfMonth().withMinimumValue()
    timeEnd = lastMonth.dayOfMonth().withMaximumValue()

这篇关于乔达时间:最近一周和一个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆