//yyyy-MM-dd
if (!/^\d{4}\-\d\d?\-\d\d?/.test(datavalue1)) {
alert("datevalue1's date format is illegal")
}
3: Convert week (excerpt from others)
import ;
import ;
import ;
import ;
public class TestDate {
public static String getWeekFromDate(String sDate,int type){
if("".equals(sDate)){
return "";
}
SimpleDateFormat df = null;
if(type==0){
df = new SimpleDateFormat("yyyy-MM-dd");
}else if(type==1){
df = new SimpleDateFormat("yyyyMMdd");
}
Date date = null;
try{
date = (sDate);
}catch(ParseException e){
();
}
Calendar cd = ();
(date);
int mydate = (Calendar.DAY_OF_WEEK);
String showDate = "";
switch (mydate) { //mydate is 1---7: Sunday, Monday, and Tuesday. . .
case 1:
showDate = "Sunday";
break;
case 2:
showDate = "Monday";
break;
case 3:
showDate = "Tuesday";
break;
case 4:
showDate = "Wednesday";
break;
case 5:
showDate = "Thursday";
break;
case 6:
showDate = "Friday";
break;
default:
showDate = "Saturday";
break;
}
return showDate;
}
}