获取上个季度的结束日期 [英] Get the end date of last quarter

查看:88
本文介绍了获取上个季度的结束日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在给定的日期,如何获得上个季度的结束日期?我需要运行一个工作,这将考虑到这一点。
编辑:第一季度是1月,2月3月;第二个是4月,5月,6月,所以;

For a given date, how to get the end date of last quarter? I need to run a job, which takes this into account. 1st quarter is Jan, Feb, Mar; 2nd is Apr, May, June, so on;

任何帮助不胜感激。感谢

Any help is appreciated. Thanks

推荐答案

基本上:


    <找出目前的季度
  1. 返回上个季度的最后一个日期(3月31日,6月30日,9月30日,12月31日)

所以要弄清楚当前季度是什么:
int quarter =(myDate.getMonth()/ 3)+ 1;
(请注意, getMonth()不赞成使用 Calendar.get(Calendar.MONTH)。)

So to figure out which is the current quarter: int quarter = (myDate.getMonth() / 3) + 1; (Note that getMonth() is deprecated in favor of Calendar.get(Calendar.MONTH).)

然后匹配上一个季度到一个日期。

Then match the previous quarter to a date.

int prevQuarter = (myDate.getMonth() / 3); 
switch(prevQuarter) {
    case 3 : 
        // return September 30
    case 2 :
        // return June 30
    case 1 :
        // return March 31
    case 0 : default :
        // return December 31
}

这篇关于获取上个季度的结束日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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