根据传入时间推算半月时间段

2023-10-12 06:38

本文主要是介绍根据传入时间推算半月时间段,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

主方法:

/*** 推算4个  半月时间段** @param condition* @return*/public EvErpPFDemandQC getDateEvTimeRangeQC(EvErpPFDemandQC condition) {Calendar calendar = Calendar.getInstance();calendar.setTime(condition.getQueryTime());int day = calendar.get(Calendar.DAY_OF_MONTH);//获取当月、下月、下下月时间组EvErpPFDemandQC dateOne = getDateFirstAndLast(condition.getQueryTime(), 0);EvErpPFDemandQC dateTwo = getDateFirstAndLast(condition.getQueryTime(), 1);EvErpPFDemandQC dateThree = getDateFirstAndLast(condition.getQueryTime(), 2);if (day <= 15) {setCondition(condition, dateOne.getFirst(), dateOne.getFifteen(), dateOne.getSixteen(), dateOne.getLast(), dateTwo.getFirst(), dateTwo.getFifteen(), dateTwo.getSixteen(), dateTwo.getLast());} else {setCondition(condition, dateOne.getSixteen(), dateOne.getLast(), dateTwo.getFirst(), dateTwo.getFifteen(), dateTwo.getSixteen(), dateTwo.getLast(), dateThree.getFirst(), dateThree.getFifteen());}return condition;}

 封装:

private void setCondition(EvErpPFDemandQC condition, Date startTimeOne, Date endTimeOne, Date startTimeTwo, Date endTimeTwo, Date startTimeThree, Date endTimeThree, Date startTimeFour, Date endTimeFour) {condition.setStartTimeOne(startTimeOne);condition.setEndTimeOne(endTimeOne);condition.setStartTimeTwo(startTimeTwo);condition.setEndTimeTwo(endTimeTwo);condition.setStartTimeThree(startTimeThree);condition.setEndTimeThree(endTimeThree);condition.setStartTimeFour(startTimeFour);condition.setEndTimeFour(endTimeFour);}

获取具体时间时钟格式值:

 /*** 获取月份开始/结束/月中日期(精确到yyyy-MM-dd HH:mm:ss)** @param queryTime* @param i* @return*/public EvErpPFDemandQC getDateFirstAndLast(Date queryTime, Integer i) {EvErpPFDemandQC condition=new EvErpPFDemandQC();Calendar calendar = Calendar.getInstance();calendar.setTime(queryTime);calendar.add(Calendar.MONTH, i);//月份int year = calendar.get(Calendar.YEAR);int month = calendar.get(Calendar.MONDAY);int maximum = calendar.getActualMaximum(Calendar.DATE);//第一天calendar.set(year, month, 1,00, 00, 00);//月份第一天condition.setFirst(calendar.getTime());//第十六天calendar.set(year, month, 16, 00, 00, 00);condition.setSixteen(calendar.getTime());//第十五天calendar.set(year, month, 15, 23, 59, 59);//最后一刻condition.setFifteen(calendar.getTime());//最后一天calendar.set(year, month, maximum, 23, 59, 59);//月份最后一天condition.setLast(calendar.getTime());return condition;}

 实体:

package cn.lionbridgecapital.ev.erp.condition.everpproplexquartz;import cn.lionbridgecapital.ev.core.pojo.QueryCondition;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;import java.util.Date;/*** @author wangguangle* @date 2019/11/15 20:05*/
@ApiModel(value = "[XXXXXX数据查询参数")
@JsonIgnoreProperties(ignoreUnknown = true)
public class EvErpPFDemandQC extends QueryCondition {@ApiModelProperty(value = "选择时间 yyyy-MM-dd HH:mm:ss - yyyy-MM-dd HH:mm:ss")private Date queryTime;/*** 月份第一天*/@JsonIgnoreprivate Date startTimeOne;/*** 第一段结束时间*/@JsonIgnoreprivate Date endTimeOne;/*** 第二段开始时间*/@JsonIgnoreprivate Date startTimeTwo;/*** 第二段结束时间*/@JsonIgnoreprivate Date endTimeTwo;/*** 第三段开始时间*/@JsonIgnoreprivate Date startTimeThree;/*** 第三段结束时间*/@JsonIgnoreprivate Date endTimeThree;/*** 第四段开始时间*/@JsonIgnoreprivate Date startTimeFour;/*** 第四段结束时间*/@JsonIgnoreprivate Date endTimeFour;/*** 月份第一天*/@JsonIgnoreprivate Date first;/*** 月份第15天*/@JsonIgnoreprivate Date fifteen;/*** 月份第16天*/@JsonIgnoreprivate Date sixteen;/*** 月份最后一天*/@JsonIgnoreprivate Date last;public EvErpPFDemandQC() {}public Date getQueryTime() {return queryTime;}public void setQueryTime(Date queryTime) {this.queryTime = queryTime;}public Date getStartTimeOne() {return startTimeOne;}public void setStartTimeOne(Date startTimeOne) {this.startTimeOne = startTimeOne;}public Date getEndTimeOne() {return endTimeOne;}public void setEndTimeOne(Date endTimeOne) {this.endTimeOne = endTimeOne;}public Date getStartTimeTwo() {return startTimeTwo;}public void setStartTimeTwo(Date startTimeTwo) {this.startTimeTwo = startTimeTwo;}public Date getEndTimeTwo() {return endTimeTwo;}public void setEndTimeTwo(Date endTimeTwo) {this.endTimeTwo = endTimeTwo;}public Date getStartTimeThree() {return startTimeThree;}public void setStartTimeThree(Date startTimeThree) {this.startTimeThree = startTimeThree;}public Date getEndTimeThree() {return endTimeThree;}public void setEndTimeThree(Date endTimeThree) {this.endTimeThree = endTimeThree;}public Date getStartTimeFour() {return startTimeFour;}public void setStartTimeFour(Date startTimeFour) {this.startTimeFour = startTimeFour;}public Date getEndTimeFour() {return endTimeFour;}public void setEndTimeFour(Date endTimeFour) {this.endTimeFour = endTimeFour;}public Date getFirst() {return first;}public void setFirst(Date first) {this.first = first;}public Date getFifteen() {return fifteen;}public void setFifteen(Date fifteen) {this.fifteen = fifteen;}public Date getSixteen() {return sixteen;}public void setSixteen(Date sixteen) {this.sixteen = sixteen;}public Date getLast() {return last;}public void setLast(Date last) {this.last = last;}
}

 

这篇关于根据传入时间推算半月时间段的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/193972

相关文章

服务器集群同步时间手记

1.时间服务器配置(必须root用户) (1)检查ntp是否安装 [root@node1 桌面]# rpm -qa|grep ntpntp-4.2.6p5-10.el6.centos.x86_64fontpackages-filesystem-1.41-1.1.el6.noarchntpdate-4.2.6p5-10.el6.centos.x86_64 (2)修改ntp配置文件 [r

MiniGPT-3D, 首个高效的3D点云大语言模型,仅需一张RTX3090显卡,训练一天时间,已开源

项目主页:https://tangyuan96.github.io/minigpt_3d_project_page/ 代码:https://github.com/TangYuan96/MiniGPT-3D 论文:https://arxiv.org/pdf/2405.01413 MiniGPT-3D在多个任务上取得了SoTA,被ACM MM2024接收,只拥有47.8M的可训练参数,在一张RTX

批处理以当前时间为文件名创建文件

批处理以当前时间为文件名创建文件 批处理创建空文件 有时候,需要创建以当前时间命名的文件,手动输入当然可以,但是有更省心的方法吗? 假设我是 windows 操作系统,打开命令行。 输入以下命令试试: echo %date:~0,4%_%date:~5,2%_%date:~8,2%_%time:~0,2%_%time:~3,2%_%time:~6,2% 输出类似: 2019_06

【MRI基础】TR 和 TE 时间概念

重复时间 (TR) 磁共振成像 (MRI) 中的 TR(重复时间,repetition time)是施加于同一切片的连续脉冲序列之间的时间间隔。具体而言,TR 是施加一个 RF(射频)脉冲与施加下一个 RF 脉冲之间的持续时间。TR 以毫秒 (ms) 为单位,主要控制后续脉冲之前的纵向弛豫程度(T1 弛豫),使其成为显著影响 MRI 中的图像对比度和信号特性的重要参数。 回声时间 (TE)

C#关闭指定时间段的Excel进程的方法

private DateTime beforeTime;            //Excel启动之前时间          private DateTime afterTime;               //Excel启动之后时间          //举例          beforeTime = DateTime.Now;          Excel.Applicat

LeetCode:64. 最大正方形 动态规划 时间复杂度O(nm)

64. 最大正方形 题目链接 题目描述 给定一个由 0 和 1 组成的二维矩阵,找出只包含 1 的最大正方形,并返回其面积。 示例1: 输入: 1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0输出: 4 示例2: 输入: 0 1 1 0 01 1 1 1 11 1 1 1 11 1 1 1 1输出: 9 解题思路 这道题的思路是使用动态规划

O(n)时间内对[0..n^-1]之间的n个数排序

题目 如何在O(n)时间内,对0到n^2-1之间的n个整数进行排序 思路 把整数转换为n进制再排序,每个数有两位,每位的取值范围是[0..n-1],再进行基数排序 代码 #include <iostream>#include <cmath>using namespace std;int n, radix, length_A, digit = 2;void Print(int *A,

dr 航迹推算 知识介绍

DR(Dead Reckoning)航迹推算是一种在航海、航空、车辆导航等领域中广泛使用的技术,用于估算物体的位置。DR航迹推算主要通过已知的初始位置和运动参数(如速度、方向)来预测物体的当前位置。以下是 DR 航迹推算的详细知识介绍: 1. 基本概念 Dead Reckoning(DR): 定义:通过利用已知的当前位置、速度、方向和时间间隔,计算物体在下一时刻的位置。应用:用于导航和定位,

LeetCode:3177. 求出最长好子序列 II 哈希表+动态规划实现n*k时间复杂度

3177. 求出最长好子序列 II 题目链接 题目描述 给你一个整数数组 nums 和一个非负整数k 。如果一个整数序列 seq 满足在下标范围 [0, seq.length - 2] 中 最多只有 k 个下标i满足 seq[i] != seq[i + 1] ,那么我们称这个整数序列为好序列。请你返回 nums中好子序列的最长长度。 实例1: 输入:nums = [1,2,1,1,3],

未雨绸缪:环保专包二级资质续期工程师招聘时间策略

对于环保企业而言,在二级资质续期前启动工程师招聘的时间规划至关重要。考虑到招聘流程的复杂性、企业内部需求的变化以及政策标准的更新,建议环保企业在二级资质续期前至少提前6至12个月启动工程师招聘工作。这个时间规划可以细化为以下几个阶段: 一、前期准备阶段(提前6-12个月) 政策与标准研究: 深入研究国家和地方关于环保二级资质续期的最新政策、法规和标准,了解对工程师的具体要求。评估政策变化可