1 15 package tutorial.forms; 16 17 import java.io.Serializable ; 18 import java.text.DateFormat ; 19 import java.text.ParseException ; 20 import java.util.Date ; 21 22 26 public class VisitorState implements Serializable 27 { 28 32 public Date getDateOfBirth() 33 { 34 return dateOfBirth; 35 } 36 37 public String getDateOfBirthAsString() 38 { 39 return DateFormat.getDateInstance().format(dateOfBirth); 40 } 41 42 46 public String getFavoriteColour() 47 { 48 return favoriteColour; 49 } 50 51 55 public String getUserName() 56 { 57 return userName; 58 } 59 60 64 public void setDateOfBirth(Date dateOfBirth) 65 { 66 this.dateOfBirth = dateOfBirth; 67 } 68 69 73 public void setFavoriteColour(String favoriteColour) 74 { 75 this.favoriteColour = favoriteColour; 76 } 77 78 public void setDateOfBirthAsString(String newDOB) throws ParseException 79 { 80 dateOfBirth = DateFormat.getDateInstance().parse(newDOB); 81 } 82 83 87 public void setUserName(String name) 88 { 89 this.userName = name; 90 } 91 92 private String userName; 93 private Date dateOfBirth = new Date (0); 94 private String favoriteColour; 95 } 96 | Popular Tags |