/*
 * ICESOFT COMMERCIAL SOURCE CODE LICENSE V 1.1
 *
 * The contents of this file are subject to the ICEsoft Commercial Source
 * Code License Agreement V1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the
 * License at
 * http://www.icesoft.com/license/commercial-source-v1.1.html
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations under
 * the License.
 *
 * Copyright 2009-2015 ICEsoft Technologies Canada, Corp. All Rights Reserved.
 */
package com.icesoft.faces.facelets.component.spinner;

import javax.faces.event.ActionEvent;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;


public class DateSpinner extends BaseSpinner {

    private int incrementField = Calendar.DATE;
    private Date value;

    public DateSpinner() {
        value = new Date();
    }

    public void decrementBtnClicked(ActionEvent evt) {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(value);
        cal.add(incrementField, -1 * incrementBy);
        value = cal.getTime();
    }

    public void incrementBtnClicked(ActionEvent evt) {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(value);
        cal.add(incrementField, incrementBy);
        value = cal.getTime();
    }

    public int getIncrementField() {
        return incrementField;
    }

    public void setIncrementField(int incrementField) {
        this.incrementField = incrementField;
    }

    public void setValue(Date date) {
        this.value = date;
    }

    public Date getValue() {
        return value;
    }


}
