Import date field xml

0

I'm doing an import of xml tags to textbox fields in Windows Form, but I'm not able to import the date fields into the correct format, for a masktextbox in date format. to display the% in% of the date in the correct format textbox .

Follow my code

DataSet ds = new DataSet();

ds.ReadXml(@"C:\Xml_Entrada\" + txt_chave.Text + ".xml");

txt_fornecedor.Text = ds.Tables["emit"].Rows[0]["xNome"].ToString();
txt_cnpj.Text = ds.Tables["emit"].Rows[0]["CNPJ"].ToString();
txt_nota.Text = ds.Tables["ide"].Rows[0]["nNF"].ToString();
txt_ie.Text = ds.Tables["emit"].Rows[0]["IE"].ToString();
txt_emissao.Text = ds.Tables["ide"].Rows[0]["dhEmi"].ToString();
txt_saida.Text = ds.Tables["ide"].Rows[0]["dhSaiEnt"].ToString();

Xml data

<dhEmi>2018-06-15T09:56:51-03:00</dhEmi>

<dhSaiEnt>2018-06-15T09:56:51-03:00</dhSaiEnt>
    
asked by anonymous 24.07.2018 / 15:25

1 answer

0

Try to do this:

// criar date time 2018-07-24 00:00:00.000
DateTime dt = new DateTime(2018, 7, 24, 00, 00, 00, 000);
String.Format("{0:dd/MM/yyyy}", dt);

You can see more about Formatting DateTime in String here .

    
24.07.2018 / 15:50