package cib4132004.tarea12;
public class Fecha {
    private int anio;private int mes;private int dia;
    /** Crea una fecha con valor 2001/01/01 */
    public Fecha() { this.anio=2001;this.mes=1;this.dia=1;}
     /** Crea una fecha con valores especificados*/
    public Fecha(int a,int m,int d) { this.anio=a;this.mes=m;this.dia=d;}
    /** Dada una cadena en formato aaaa/mm/dd, la interpreta y almacena
     *  en los campos anio, mes y dia**/
    public void convertir(String cadenaFecha) {
         String sAnio = cadenaFecha.substring(0,4);      
         String sMes = cadenaFecha.substring(5,7);
         String sDia = cadenaFecha.substring(8);   
         this.anio = Integer.valueOf(sAnio).intValue();
         if (sMes.charAt(0) == '0') sMes = String.valueOf(sMes.charAt(1));
         this.mes = Integer.valueOf(sMes).intValue();
          if (sDia.charAt(0) == '0') sMes = String.valueOf(sDia.charAt(1));
         this.dia = Integer.valueOf(sDia).intValue();
    }
    private String cadenaFormato;
    /**Constante que representa el caracter separador por omision*/
    public final static char SEPARADOR_DIAGONAL= '/';
    /** Retorna la representacion de este objeto en formato aaaa/mm/dd*/
    public String getCadenaFormato() {
       StringBuffer buff= new StringBuffer();  
       buff.append(this.anio);buff.append(SEPARADOR_DIAGONAL);
       buff.append(this.mes);buff.append(SEPARADOR_DIAGONAL);
       buff.append(this.dia);
       return buff.toString();
    }
    
    /** Getter for property anio.
     * @return Value of property anio.
     */
    public int getAnio() {
        return anio;
    }    
    
    /** Setter for property anio.
     * @param anio New value of property anio.
     */
    public void setAnio(int anio) {
        this.anio = anio;
    }
    
    /** Getter for property dia.
     * @return Value of property dia.
     */
    public int getDia() {
        return dia;
    }
    
    /** Setter for property dia.
     * @param dia New value of property dia.
     */
    public void setDia(int dia) {
        this.dia = dia;
    }
    
    /** Getter for property mes.
     * @return Value of property mes.
     */
    public int getMes() {
        return mes;
    }
    
    /** Setter for property mes.
     * @param mes New value of property mes.
     */
    public void setMes(int mes) {
        this.mes = mes;
    }
    
}
