Date 比较SAPUI5中的两个日期

Date 比较SAPUI5中的两个日期,date,sapui5,sap-fiori,Date,Sapui5,Sap Fiori,我想比较,日期A是否大于日期B。但我总是得到错误,即使日期A大于日期B var oDatepicker = this.getView().byId("Date"); var oFormat = sap.ui.core.format.DateFormat.getInstance({ pattern: "d.M.y" }); var oDate = oFormat.format(new Date());

我想比较,日期A是否大于日期B。但我总是得到错误,即使日期A大于日期B

var oDatepicker = this.getView().byId("Date");
            var oFormat = sap.ui.core.format.DateFormat.getInstance({ pattern: "d.M.y" });
            var oDate = oFormat.format(new Date());
            var oDatepickerParsed = oFormat.parse(oDatepicker.getValue());
            if(oFormat.format(oDatepickerParsed) > oDate){
                return true;
            } else {
                return false;   
            }
我试图基于oDatepicker.getValue()实例化一个日期对象,以将日期对象与日期对象进行比较,但出现了一些错误

var oDateObject = new Date(oDatepicker.getValue())

oDatepicker.getValue()是='01.11.2020'类型的字符串。有什么问题吗?

您是否尝试了方法
getDateValue()
,该方法提供了“作为JavaScript日期对象的日期。这独立于任何格式化程序。”

您是否尝试了方法
getDateValue()
,该方法提供了“作为JavaScript日期对象的日期。这独立于任何格式化程序。”

实际目标是什么?“if(of format.format(oDatepickerParsed)>oDate)”似乎在比较两个字符串。建议您使用日期类型进行比较。实际目标是什么?“if(of format.format(oDatepickerParsed)>oDate)”似乎在比较两个字符串。建议您使用日期类型进行比较。