⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userform.java

📁 通讯录一个供大家参考
💻 JAVA
字号:
package com.lideedu.huang.addressBook.struts.form;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import org.apache.struts.validator.ValidatorForm;

public class UserForm extends ValidatorForm {

	private String username;
	private String password;
	private String password_2;
	private short sex;
	private short age;
	private String year;
	private String month;
	private String date;
	private Date birthDay;
	private String[] hobby;
	private Date regDate;
	
	private static final String DATE_FORMATE = "yyyy-MM-dd";

	//初始化
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		
		username = null;
		password = null;
		password_2 = null;
		sex = 0;
		age=21;
       
		ArrayList yearOptions = new ArrayList();
		ArrayList monthOptions = new ArrayList();
		ArrayList dateOptions = new ArrayList();

		for (int i = 1970; i <=new Date().getYear()+1900; i++) {
			
			LabelValueBean option = new LabelValueBean(String.valueOf(i),
					String.valueOf(i));
			yearOptions.add(option);
		}
		
		for (int i = 1; i <= 12; i++) {
			
			LabelValueBean option=null;
			if(i<10)
		         option = new LabelValueBean("0"+String.valueOf(i),"0"+String.valueOf(i));			   
			else
			     option = new LabelValueBean(String.valueOf(i),String.valueOf(i));							   
			monthOptions.add(option);
		}
		
		for (int i = 1; i <= 31; i++) {
			LabelValueBean option=null;
			if(i<10)
				option = new LabelValueBean("0"+String.valueOf(i),"0"+String.valueOf(i));
			else
				option = new LabelValueBean(String.valueOf(i),String.valueOf(i));	
			dateOptions.add(option);
		}
		
		request.setAttribute("yearOptions", yearOptions);
		request.setAttribute("monthOptions", monthOptions);
		request.setAttribute("dateOptions", dateOptions);
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public short getAge() {
		return age;
	}

	public void setAge(short age) {
		this.age = age;
	}

	public Date getBirthDay() {
		return birthDay;
	}

	public void setBirthDay(Date birthDay) {
		this.birthDay = birthDay;
		SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_FORMATE);
		String str=dateFormat.format(birthDay);
		String []d=str.split("-");
		this.year=d[0];
		this.month=d[1];
		this.date=d[2];
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
		SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_FORMATE);
		try {
			this.birthDay=dateFormat.parse(getYear()+"-"+getMonth()+"-"+getDate());
		} catch (ParseException e) {
			e.printStackTrace();
		}	
	}

	public String[] getHobby() {
		return hobby;
	}

	public void setHobby(String[] hobby) {
		this.hobby = hobby;
	}

	public String getMonth() {
		return month;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public String getPassword_2() {
		return password_2;
	}

	public void setPassword_2(String password_2) {
		this.password_2 = password_2;
	}

	public short getSex() {
		return sex;
	}

	public void setSex(short sex) {
		this.sex = sex;
	}

	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}

	public Date getRegDate() {
		return new Date();
	}

	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -