Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/04/2011, 16:17
lincolnf_2
 
Fecha de Ingreso: abril-2011
Ubicación: lima
Mensajes: 134
Antigüedad: 13 años, 1 mes
Puntos: 3
Sonrisa fechas con JFormattedTextField

hola amigos tengo este codigo.


public class Fechas extends MaskFormatter {
public Fechas()throws ParseException{
super("##/##/####");

}
private SimpleDateFormat formato=new SimpleDateFormat("dd/MM/yyyy");
@Override
public Object stringToValue(String text)throws ParseException{
return formato.parse(text);
}
@Override
public String valueToString(Object value)throws ParseException{
if (value instanceof Date) {
return formato.format((Date)value);

}
return formato.format(new Date());
}
}

esta es la clase que he creado para la mascara y aki el codigo del JFormattedTextField



try{
JFormattedTextField fecha=new JFormattedTextField(new Fechas());
this.fecha.setValue(new Date());
}
catch(Exception e){System.out.print(e.getMessage())}


bueno todo bien hasta aki, funciona de maravilla, lo que quiero hacer es que no ingresen valores mas 31 en los dias y mas de 12 en los meses, les agradecere cualquier ayuda..