c# - Conversion of text data into date -


I have a situation in which I have to change the text data in a date.

I have used the following code to do this!


  string s = textbox1.Text; If (String.IsNullOrEmpty (s)) {textBox2.Text = "Please enter a date."; } And {datetime DT = date time.ps (s); String day = dt.day.ToString (); String month = dt.Month.ToString (); String year = dt. year. Toasting (); S = day + "/" + month + "/" + year; Textbox2.Text = s; }  

This will only change the following formats of data.


10/10/09 or 10/10/2009 ---- Changed Date ------ 10/10/2009

12/13/2009 Or 12/13/9 ---- converted date ------- 12/13/2009

10/16 ---- changed date ---------- ------------- 16/10/2009

2009/12/10 ---- Date changed -------------- ---- 10/12/2009


The following formats are not found


16/10-dd / mm

06020 9 or 06022009 ddmmyyyy

13122009 mmddyyyy

20091213 yyyymmdd

20091312 yyyyddmm

20.07.2009 / 20.07 2009 / 20-07-2009 / 20-07-09


Anybody can help me with this I am very new to c #

Parsing is a bit more complicated than dates, I'm scared. It will depend on your culture / country settings to see the overload ...

Also keep in mind that when you output your date, you can also use it:

  String.Format ("{0: dd / MM / yyyy}", dt)  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -