1、 JAVA 时间格式化学习:
————写法1:
public static void main(String[] args) {
DateFormat df = new SimpleDateFormat("yyyy年MM月dd日");//设置日期格式
Date date = new Date(System.currentTimeMillis());//获取当前时间~
String dateStr = df.format(date);//用格式格式化Date对象~
System.out.println(dateStr); }
————写法2:
public static void main(String[] args) {
String str = "2008-15-20";
String str0[] = str.split("-");
String str1 = str0[0]+"年"+str0[1]+"月"+str0[2]+"日";
System.out.println(str1);//结果为2008年15月20日 }
2、 邮件格式的js验证:
function checkmail()
{
var mail = document.form1.youjian.value
var ts = document.getElementById("youjiants");
illegalemail = !(/^[/w/-/_/.u4e00-/u9fa5]+@[/w/-/_u4e00-/u9fa5]+(/.[/w/-/_u4e00-/u9fa5]+)+$/.test(mail));
if(illegalemail)
{
ts.innerHTML =" " + imgwrong + "邮件格式不对!";
ts.style.color="#000000";
}