2014-01-30 56 views
0

我需要相关robotium script.My方案帮助像“以我AUT当前日期可用‘2014年1月30日’。所以我需要验证其是否当前日期或不是。当前日期验证

回答

1

您可以解析StringDate,并与今天相比较,或者您可以格式化今天的日期为String,并与现有的日期进行检查。下面是如何使用后者的逻辑实现它的一个例子。

String day = "30 january 2014"; // Available Date 
DateFormat df = new SimpleDateFormat("dd MMMM yyyy"); // DateFormat matching your available date 
if (df.format(new Date()).equalsIgnoreCase(day)) { // check for equality, ignoring the case 
    // It is today's date if the control comes here. 
} else { 
    // It is not today's date if the control comes here. 
}