亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在兩個時間戳之間存在的 java fx 8 表視圖中顯示數據

如何在兩個時間戳之間存在的 java fx 8 表視圖中顯示數據

炎炎設計 2023-03-23 15:10:04
我有一個問題,我找不到解決方案。我正在嘗試過濾我的 javafx8 tableview,但我遇到了問題。我不知道如何只顯示兩個時間戳之間存在的數據。編輯:明確地說,我想知道如何使用文本字段為行配置開始和結束PS:我的tableview截圖:我已經看過https://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/。我在創建適當的 時遇到了麻煩Predicate,他們在 tuto 中向您展示了如何僅顯示具有相同信息的信息。我想顯示兩者之間存在的信息。PS:項目類型是時間戳
查看完整描述

1 回答

?
12345678_0001

TA貢獻1802條經驗 獲得超5個贊

confirmdatebtn1.setOnAction(new EventHandler<ActionEvent>(){

                   @Override public void handle(ActionEvent e) {

                        filterData.setPredicate(table -> {

                            if ((todatetxt.getText() == null &&fromdatetxt.getText() == null) ||

                                    (todatetxt.getText().isEmpty()&&fromdatetxt.getText().isEmpty()) ) {

                                return true;}

                try {

                        String fromtext = fromdatetxt.getText();

                        String totext = todatetxt.getText();

                        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");

                        Date date1 = null;

                        Date date2 = null;

                        Timestamp timestamp1 = null;

                        Timestamp timestamp2 = null;


                        if(todatetxt.getText().isEmpty() && !fromdatetxt.getText().isEmpty()) {

                                date1 = format.parse(fromtext+" 00:00:00.000");

                                timestamp1 = new java.sql.Timestamp(date1.getTime());

                                if (table.getTime_of_action().after(timestamp1) ) 

                                {return true;}

                        }

                        if(!todatetxt.getText().isEmpty() && fromdatetxt.getText().isEmpty()) {

                            date2 = format.parse(totext+" 23:59:59.000");

                            timestamp2 = new java.sql.Timestamp(date2.getTime());

                            if (table.getTime_of_action().before(timestamp2) ) 

                            {return true;}

                        }

                        if(!todatetxt.getText().isEmpty()  && !fromdatetxt.getText().isEmpty()) {

                            date1 = format.parse(fromtext+" 00:00:00.000");

                            date2 = format.parse(totext+" 23:59:59.999");


                            timestamp1 = new java.sql.Timestamp(date1.getTime());

                            timestamp2 = new java.sql.Timestamp(date2.getTime());


                            if (table.getTime_of_action().before(timestamp2) &&table.getTime_of_action().after(timestamp1)) 

                            {return true;}

                        }


                    } catch (Exception e1) {


                    }


                        return false; 

            });} });*** i wrote this code and it came out good so my probleme is resolved thanks to your help guys***



查看完整回答
反對 回復 2023-03-23
  • 1 回答
  • 0 關注
  • 130 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號