Package reportgen.math.constants.dateval

Source Code of reportgen.math.constants.dateval.MathExpressionConstValueDate

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package reportgen.math.constants.dateval;

import reportgen.math.constants.MathExpressionConstAbstract;
import reportgen.utils.ReportException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import org.jdom.Element;
import reportgen.math.constants.MathExpressionConstValueAbstract;
import reportgen.prototype.context.Context;
import reportgen.prototype.context.group.ContextGroup;

/**
*
* @author axe
*/

public class MathExpressionConstValueDate extends MathExpressionConstValueAbstract<Date> {

    public static final ContextGroup GROUP = new DateContextGroup();

    public static final String TAG ="date";
    private static DateFormat dateformat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.FRENCH);

    public MathExpressionConstValueDate(Context context) {
        super(context);
    }

    public MathExpressionConstValueDate(Date value, Context context) {
        super(value, context);
    }

    public MathExpressionConstValueDate(Element element,
            Context context) throws ReportException {
        super(element, context);
        try {
            value = dateformat.parse(element.getText());
        } catch (Exception ex) {
            throw new ReportException("Ошибка при распозновании константы: "
                    + ex.getLocalizedMessage());
        }
    }
    @Override
    protected String valueToXML() {
        return dateformat.format(value);
    }

    @Override
    public MathExpressionConstValueDate makeClone() throws ReportException {
        return new MathExpressionConstValueDate(toXML(), getParentContext());
    }

    @Override
    public MathExpressionConstValueDate make(Date value) {
        return new MathExpressionConstValueDate(value, getParentContext());
    }

    @Override
    public ContextGroup getContextGroup() {
        return GROUP;
    }

    @Override
    protected String getRootTag() {
        return TAG;
    }

    @Override
    protected Date initDefault() {
        return new Date();
    }


}
TOP

Related Classes of reportgen.math.constants.dateval.MathExpressionConstValueDate

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.