Parse C# string to hh:mm:ss -


given 2 strings

string date = "02mar13"; string duration = "03.20min"; 

how parse them datetime , show them in following format

string date = "02 march 2013"; string duration = "00:03:20"; 

i went through list here no 1 match requirements.

you need parse these using custom date , time format string, , output using 1 well:

datetime dt = datetime.parseexact(date + duration,                                    "ddmmmyymm.ss'min'",                                    cultureinfo.invariantculture);  string newdate = dt.tostring("dd mmmm yyyy"); string newduration = dt.tostring("hh:mm:ss"); 

things note: using 'min' represent min literal in string - part of custom format strings, allowing inner string literals.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -