我有以下日期格式:DateFormat df = new SimpleDateFormat("EEEEE, LLLL d");
和以下字符串数组:
String[] Days = {
"Tuesday, January 1",
"Monday, January 21",
"Sunday, February 10",
"Tuesday, February 12",
"Wednesday, February 13",
"Monday, February 18",
"Sunday, February 24",
"Tuesday, March 26",
"Wednesday, March 27",
"Thursday, March 28",
"Friday, March 29",
"Monday, April 1",
"Tuesday, April 2",
"Thursday, May 2",
"Friday, May 3",
"Thursday, May 9",
"Wednesday, May 15",
"Thursday, May 16",
"Monday, May 27",
"Thursday, July 4",
"Wednesday, August 7",
"Thursday, August 8",
"Friday, August 9",
"Thursday, August 15",
"Monday, September 2",
"Thursday, September 5",
"Friday, September 6",
"Saturday, September 14",
"Thursday, September 19",
"Friday, September 20",
"Thursday, September 26",
"Friday, September 27",
"Monday, October 14",
"Tuesday, October 15",
"Wednesday, October 16",
"Thursday, October 17",
"Friday, November 1",
"Sunday, November 3",
"Tuesday, November 5",
"Monday, November 11",
"Thursday, November 28",
"Sunday, December 8",
"Wednesday, December 25"
};
我该如何进行比较,所以假设df
=Friday, September 27
这将是真的,因为字符串在数组Days
中具有值“9 月 27 日星期五”。
我做了以下但我的小部件FC:
for (int j=0; j<=suspendedDates.length;j++) {
if (df.format(new Date()) == suspendedDates[j]) {
views.setTextViewText(R.id.tvParkStatus, "Parking Suspended");
}
else {
views.setTextViewText(R.id.tvParkStatus, "Parking Not Suspended");
}
}