① 若报表强制参评人员名单在10月1日至12月31日刷新则用下一年3月31日来计算员工暂定级是否满一年若在1月1号至3月31日之间刷新则用当年3月31日来计算员工暂定级是否满一年若报表是在4月1日至9月30日之间刷新则用当年9月30日来计算员工暂定级是否满一年;② 若在暂定级内发生跨二级序列调动需要以调动时间作为暂定级开始时间;写一个java
根据以上规则计算员工暂定级是否满一年的Java代码可以如下所示:
import java.time.LocalDate;
public class Employee {
private String name;
private LocalDate provisionalLevelStartDate;
public Employee(String name, LocalDate provisionalLevelStartDate) {
this.name = name;
this.provisionalLevelStartDate = provisionalLevelStartDate;
}
public boolean isProvisionalLevelOneYearComplete() {
LocalDate currentDate = LocalDate.now();
if (provisionalLevelStartDate.getMonthValue() >= 10 && provisionalLevelStartDate.getDayOfMonth() == 1
&& currentDate.getMonthValue() == 3 && currentDate.getDayOfMonth() == 31) {
return true;
}
if (provisionalLevelStartDate.getMonthValue() >= 1 && provisionalLevelStartDate.getMonthValue() <= 3
&& provisionalLevelStartDate.getDayOfMonth() == 1 && currentDate.getMonthValue() == 3
&& currentDate.getDayOfMonth() == 31) {
return true;
}
if (provisionalLevelStartDate.getMonthValue() >= 4 && provisionalLevelStartDate.getMonthValue() <= 9
&& provisionalLevelStartDate.getDayOfMonth() == 1 && currentDate.getMonthValue() == 9
&& currentDate.getDayOfMonth() == 30) {
return true;
}
return false;
}
public static void main(String[] args) {
Employee employee = new Employee("John", LocalDate.of(2021, 1, 1));
System.out.println("Is provisional level one year complete? " + employee.isProvisionalLevelOneYearComplete());
}
}
在上述代码中,我们创建了一个Employee类,包含员工姓名和暂定级开始日期。isProvisionalLevelOneYearComplete()方法用于判断员工暂定级是否满一年。根据给定的规则,我们比较暂定级开始日期和当前日期来确定是否满足条件。在main()方法中,我们创建了一个Employee对象,并调用isProvisionalLevelOneYearComplete()方法来检查暂定级是否满一年
原文地址: https://www.cveoy.top/t/topic/iRPK 著作权归作者所有。请勿转载和采集!