Click here to Skip to main content
15,885,914 members
Home / Discussions / C#
   

C#

 
AnswerRe: AppDomain Problem Pin
PIEBALDconsult14-Oct-09 13:29
mvePIEBALDconsult14-Oct-09 13:29 
AnswerIgnore repost Pin
Not Active14-Oct-09 14:41
mentorNot Active14-Oct-09 14:41 
AnswerRe: AppDomain Problem Pin
Not Active14-Oct-09 14:43
mentorNot Active14-Oct-09 14:43 
GeneralRe: AppDomain Problem Pin
dataminers14-Oct-09 21:19
dataminers14-Oct-09 21:19 
AnswerMy Vote of 1: Do not repost Pin
Keith Barrow15-Oct-09 1:14
professionalKeith Barrow15-Oct-09 1:14 
Questionwhere to chane the company name in vs2005 Pin
cjoki14-Oct-09 11:54
cjoki14-Oct-09 11:54 
AnswerRe: where to chane the company name in vs2005 Pin
cjoki14-Oct-09 12:20
cjoki14-Oct-09 12:20 
QuestionWhy changing the CurrentCulture.DateTimeFormat.ShortTimePattern doesn't affect the DateTime.now format Pin
Member 372226114-Oct-09 9:45
Member 372226114-Oct-09 9:45 
Hi All,

See this code below:

string format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern;
Console.WriteLine("Before Changing:");
Console.WriteLine(format);
Console.WriteLine(DateTime.Now);

Console.WriteLine("After Changing:");
CultureInfo ci = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.Name);
ci.DateTimeFormat.ShortTimePattern = "hh:mm:ss tt";
Thread.CurrentThread.CurrentUICulture = ci;
Thread.CurrentThread.CurrentCulture = ci;
format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern;
Console.WriteLine(format);
Console.WriteLine(DateTime.Now);

Console.ReadKey();


Output:<br />
Before Changing:<br />
h:mm tt<br />
10/14/2009 21:47:53<br />
After Changing:<br />
hh:mm:ss tt<br />
10/14/2009 21:47:53


I want the Console.WriteLine(DateTime.Now); will print the date time
now of the application with AM/PM in the end 12h format.
I dont want to use the DateTime.Now.ToString("hh:mm:ss tt") for this action.

How can I change my UI thread/main thread with a CurrentCulture that by default will make the DateTime.Now Time to be with AM/PM(12h time) at the end??

Thanks!
Ronen
AnswerRe: Why changing the CurrentCulture.DateTimeFormat.ShortTimePattern doesn't affect the DateTime.now format Pin
DaveyM6914-Oct-09 10:29
professionalDaveyM6914-Oct-09 10:29 
GeneralRe: Why changing the CurrentCulture.DateTimeFormat.ShortTimePattern doesn't affect the DateTime.now format Pin
Member 372226114-Oct-09 20:21
Member 372226114-Oct-09 20:21 
GeneralRe: Why changing the CurrentCulture.DateTimeFormat.ShortTimePattern doesn't affect the DateTime.now format Pin
DaveyM6914-Oct-09 22:33
professionalDaveyM6914-Oct-09 22:33 
GeneralRe: Why changing the CurrentCulture.DateTimeFormat.ShortTimePattern doesn't affect the DateTime.now format Pin
Richard MacCutchan14-Oct-09 22:36
mveRichard MacCutchan14-Oct-09 22:36 
QuestionList Objects to Xml Method Pin
AndyASPVB14-Oct-09 9:08
AndyASPVB14-Oct-09 9:08 
AnswerRe: List Objects to Xml Method Pin
DaveyM6914-Oct-09 9:22
professionalDaveyM6914-Oct-09 9:22 
GeneralRe: List Objects to Xml Method Pin
AndyASPVB14-Oct-09 9:41
AndyASPVB14-Oct-09 9:41 
GeneralRe: List Objects to Xml Method Pin
Not Active14-Oct-09 10:18
mentorNot Active14-Oct-09 10:18 
GeneralRe: List Objects to Xml Method Pin
DaveyM6914-Oct-09 10:20
professionalDaveyM6914-Oct-09 10:20 
Questionerror sending email using Networkcredential Pin
Jassim Rahma14-Oct-09 8:32
Jassim Rahma14-Oct-09 8:32 
AnswerRe: error sending email using Networkcredential Pin
Abhijit Jana14-Oct-09 8:42
professionalAbhijit Jana14-Oct-09 8:42 
GeneralRe: error sending email using Networkcredential Pin
Jassim Rahma14-Oct-09 9:41
Jassim Rahma14-Oct-09 9:41 
GeneralRe: error sending email using Networkcredential Pin
Abhijit Jana14-Oct-09 17:18
professionalAbhijit Jana14-Oct-09 17:18 
QuestionXML VALIDATION Pin
waqasm14-Oct-09 8:23
waqasm14-Oct-09 8:23 
QuestionC# console application to dll and register..... Pin
greendragons14-Oct-09 8:20
greendragons14-Oct-09 8:20 
AnswerRe: C# console application to dll and register..... Pin
Dave Kreskowiak14-Oct-09 8:28
mveDave Kreskowiak14-Oct-09 8:28 
GeneralRe: C# console application to dll and register..... Pin
greendragons14-Oct-09 8:31
greendragons14-Oct-09 8:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.