Tags » Code Snippet

String Format for DateTime

// create date time 2008-03-09 16:05:07.123
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);

String.Format("{0:t}", dt);  // "4:05 PM"                        
String.Format("{0:d}", dt);  // "3/9/2008"                       
String.Format("{0:T}", dt);  // "4:05:07 PM"                     
String.Format("{0:D}", dt);  // "Sunday, March 09, 2008"         
String.Format("{0:f}", dt);  // "Sunday, March 09, 2008 4:05 PM" 
String.Format("{0:F}", dt);  // "Sunday, March 09, 2008 4:05:07 PM"
String.Format("{0:g}", dt);  // "3/9/2008 4:05 PM"
String.Format("{0:G}", dt);  // "3/9/2008 4:05:07 PM"
String.Format("{0:m}", dt);  // "March 09"
String.Format("{0:y}", dt);  // "March, 2008"
String.Format("{0:r}", dt);  // "Sun, 09 Mar 2008 16:05:07 GMT"
String.Format("{0:s}", dt);  // "2008-03-09T16:05:07"
String.Format("{0:u}", dt);  // "2008-03-09 16:05:07Z"

// www.csharp-examples.net/string-format-datetime


Tech

Simple Connection Pool Manager in Scala

For large applications that make lots of requests to an outside application, it’s often important, for the sake of performance, to use a pool of connections to said service. 530 more words

Programming