NFe.ConvertTxt.ConversaoTXT.getDate2 C# (CSharp) Method

getDate2() public method

getDateTime2
public getDate2 ( TpcnTipoCampo Tipo, string value ) : System.DateTime
Tipo TpcnTipoCampo
value string
return System.DateTime
        public DateTime getDate2(TpcnTipoCampo Tipo, string value)
        {
            if (string.IsNullOrEmpty(value))
                return DateTime.MinValue;

            if (value.Contains("-"))
                return this.getDateTime(Tipo, value);

            try
            {
                int _ano = Convert.ToInt16(value.Substring(0, 4));
                int _mes = Convert.ToInt16(value.Substring(4, 2));
                int _dia = Convert.ToInt16(value.Substring(6, 2));
                return new DateTime(_ano, _mes, _dia);
            }
            catch
            {
                throw new Exception("Data inválida do conteudo [" + value + "]");
            }
        }