首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sailpoint java eclipse空值?

Sailpoint java eclipse空值?
EN

Stack Overflow用户
提问于 2022-08-25 08:31:54
回答 1查看 56关注 0票数 0

在Eclipse中的基准测试中有两个字符串值。只要其中一个是空的。用户可用于登录和注销。

我希望分配一个空值,因为不是每个用户都有一个离开日期。

我将使用我的工程工作在帆点软件。

月食

代码语言:javascript
复制
public static void main(String[] args) {
        // TODO Auto-generated method stub
        
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("dd/MM/yyyy");
        String tarihEnd= null; 
        String tarihStart = "18/01/2023";
        
       try {
        if  (tarihEnd !=null || tarihStart!=null)
        {
            
            LocalDate jobLeavingDay = LocalDate.parse(tarihEnd,sdf);
            LocalDate jobStartingDay = LocalDate.parse(tarihStart,sdf);
            
                 LocalDateTime beginDate = jobLeavingDay.atTime(8, 00);
                 LocalDateTime endDate = jobLeavingDay.atTime(16, 30);
                 LocalDateTime nowDateTime = LocalDateTime.now();
                
            if(nowDateTime.compareTo(beginDate)==1 && nowDateTime.compareTo(endDate)==-1) 
                      System.out.println("False1");
            
                else if(jobLeavingDay.compareTo(nowDateTime.toLocalDate())<0 && jobStartingDay.compareTo(nowDateTime.toLocalDate())<0) // jobleaving and jobstarting < nowdatetime = true
                    System.out.println("True1");

                else if (jobStartingDay.compareTo(nowDateTime.toLocalDate())<0 && jobLeavingDay.compareTo(nowDateTime.toLocalDate()) >0) 
                    System.out.println("False2");
            
                else if (jobStartingDay.compareTo(nowDateTime.toLocalDate())>0)
                    System.out.println("True");
            
                else if (jobStartingDay.compareTo(nowDateTime.toLocalDate())<0)
                    System.out.println("False3"); //jobleaving null, jobStarting_NowDate den once gelirse
        }} catch (Exception e) {
            
              tarihStart=null;
               tarihEnd=null;
            
            }     
    }
}

帆点

身份证明在这里完成。从csv文件中提取信息。

示例:将在2022年20/12/2022开始工作的用户的实际值应该为真。

但是,即使我把>符号或给isAfter,它得到的每一次假值。

在这里编辑有什么意义?

代码语言:javascript
复制
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import sailpoint.object.*;

DateTimeFormatter sdf= DateTimeFormatter.ofPattern("dd/MM/yyyy");

Attributes attrs = link.getAttributes();
String tarih = attrs.getString("JobLeaveDate");
String tarih2 = attrs.getString("JobStartDate");

try{
if(tarih!=null || tarih2!=null {

LocalDate jobLeavingDay = LocalDate.parse(tarih, sdf);
LocalDate jobStartingDay = LocalDate.parse(tarih2, sdf);
LocalDate nowDate = LocalDate.now();

         //LocalDateTime beginDate = jobLeavingDay.atTime(8, 00);
        // LocalDateTime endDate = jobLeavingDay.atTime(16, 30);
                // LocalDateTime nowDateTime = LocalDateTime.now();

if (jobStartingDay.compareTo(nowDate)>0)
stat="True";

else if (jobStartingDay.compareTo(nowDate)<0)
stat="False";
} } catch (Exception e) {
  
           tarih=null;
        }   
return (stat)  
EN

回答 1

Stack Overflow用户

发布于 2022-08-25 11:11:51

用你的第一个密码。这是例外,因为tarihEnd = null,但您也使用它的行:

LocalDate jobLeavingDay = LocalDate.parse(tarihEnd,sdf);

使用yout代码第二,请您提供价值税,tarih2。

低声我的代码:

代码语言:javascript
复制
 public static void main(String[] args) {
    DateTimeFormatter sdf = DateTimeFormatter.ofPattern("dd/MM/yyyy");

    String tarihEnd = "26/08/2022";
    String tarihStart = "18/01/2023";
    String stat = "";
    try {
        if (tarihEnd != null || tarihStart != null) {
            LocalDate jobLeavingDay = LocalDate.parse(tarihEnd, sdf);
            LocalDate jobStartingDay = LocalDate.parse(tarihStart, sdf);
            LocalDate nowDate = LocalDate.now();

            if (jobStartingDay.isAfter(nowDate)) {
                stat = "True";
            } else if (jobStartingDay.compareTo(nowDate) < 0)
                stat = "False";
            }
    } catch (Exception e) {
        tarihStart = null;
        tarihEnd = null;
    }
    System.out.println(stat);
}

图书馆的贝娄代码:

代码语言:javascript
复制
public boolean isAfter(ChronoLocalDate other) {
    if (other instanceof LocalDate) {
        return this.compareTo0((LocalDate)other) > 0;
    } else {
        return super.isAfter(other);
    }
}

以及:

代码语言:javascript
复制
int compareTo0(LocalDate otherDate) {
    int cmp = this.year - otherDate.year;
    if (cmp == 0) {
        cmp = this.month - otherDate.month;
        if (cmp == 0) {
            cmp = this.day - otherDate.day;
        }
    }

    return cmp;
}

如您所见,我们使用LocalDate,因此isAfter方法将返回:this.compareTo0((LocalDate)other) > 0; here other = now()

我的代码,jobStartingDay = 18/01/2023,然后是cmp = 2023-2022=1,因此是isAfter = true。18/01/2023年是今天之后的日子,isAfter = true是正确的。更容易,你应该转换为长和工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73484316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档