package siprp.planoactuacao.print;

import java.util.Calendar;
import java.util.Date;

import org.jdom.Element;

import com.evolute.utils.date.DateUtils;

public class DataToPrint
	implements PrintableInterface
{
	protected String tag;
	protected Date data;
	
	public DataToPrint( String tag, Date data )
	{
		super();
		this.tag = tag;
		this.data = data;
	}

	@Override
	public Element toJdomElement() throws Exception
	{
		Element dataElement = new Element( tag );
		Calendar cal = Calendar.getInstance();
		cal.setTime( data );
		int ano = cal.get( Calendar.YEAR );
		int mes = cal.get( Calendar.MONTH );
		int dia = cal.get( Calendar.DAY_OF_MONTH );
		Element anoElement = new Element( "ano" );
		anoElement.setText( "" + ano );
		dataElement.addContent( anoElement );
		Element mesElement = new Element( "mes" );
		mesElement.setText( "" + ( mes + 1 ) );
		dataElement.addContent( mesElement );
		Element mesExtensoElement = new Element( "mes-extenso" );
		mesExtensoElement.setText( DateUtils.MONTHS_FULL_PT[ mes ] );
		dataElement.addContent( mesExtensoElement );
		Element diaElement = new Element( "dia" );
		diaElement.setText( "" + dia );
		dataElement.addContent( diaElement );
		return dataElement;
	}

	public String getTag()
	{
		return tag;
	}

	public void setTag( String tag )
	{
		this.tag = tag;
	}

	public Date getData()
	{
		return data;
	}

	public void setData( Date data )
	{
		this.data = data;
	}
}
