Joda时间只比较

时间:2015-01-17 09:32:54

标签: java jodatime

我试图比较时间,并在尝试比较时遇到问题。我使用JODA提取UTC时间如下

DateTime ld_currentTime = DateTime.now( DateTimeZone.UTC );
Date ld_time = ld_currentTime.toDate();

现在,我想将此时间与字符串变量中的另一个时间进行比较,如

String start = "09:00";

我寻求的所需功能要么过时,要么无法解析功能。例如,isAfter()寻找一个长变量作为参数。其他功能也是如此。但我正在将当前时间转换为UTC,之前的处理。 似乎遗漏的唯一选择是分别将小时和分钟提取到int变量并处理它们。

任何建议都表示赞赏。

1 个答案:

答案 0 :(得分:0)

找到合理的解决方案。没有尝试任何差异。任何意见/建议表示赞赏。让我检查它是否在所有情况下都能正常工作。

for (int li_tmp_ctr=0;   li_tmp_ctr < gi_total_elements;   ++li_tmp_ctr){
    LocalTime now = LocalTime.now( DateTimeZone.UTC );
    LocalTime limit = new LocalTime( IX_Container[li_tmp_ctr].utc_open_time );

    if (now.isAfter( limit) ){
        //  Write the information to the appropriate file. 
        lb_startFlag = true;
    }
}