如何将DateTime文化从英语转换为古吉拉特语 [英] How to Convert Culture of DateTime from English to Gujarati

查看:117
本文介绍了如何将DateTime文化从英语转换为古吉拉特语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在使用一个Web应用程序,我有一个日期时间选择器。当我改变应用程序英语文化到古吉拉特语日期时间选择器格式也改变在古吉拉特语和数据库中我有日期时间与日期格式,



但是当我试着将那个日期存入古吉拉特语,它给我转换错误。



我尝试用英语改变文化到古吉拉特语但是它仍然不起作用..



我怎么做才能帮帮我..







感谢和问候

解决方案

1.当前线程有两个属性来控制当前文化:

- Thread.CurrentThread.CurrentUICulture - 控制UI部分

- Thread.CurrentThread.CurrentCulture - 控制逻辑部分,包括将DateTime转换为SQL服务器所需的文化。



2.在你的代码中,在转换数据之前(DateTime,还要来自UI的数值)你应该将它转换为DateTime值,你应该使用第二个当前文化属性,假设你将它设置为你的逻辑(和你的SQL服务器)所需的文化信息,如下面的例子:

 DateTime myDate; 
DateTime.TryParse(dateStringFromUI,System.Threading.Thread.CurrentThread.CurrentCulture,DateTimeStyles.AllowWhiteSpaces, out myDate)


Hello To All,

I am working with one web application inside that i have One Date-time picker. when i have change Culture of Application English to Gujarati Date-time picker format also change in Gujarati and in database i have date-time with date format,

But when i try to stored that date into Gujarati it throw me conversion error.

I try with changing culture with English to Gujarati but still it's not work..

How i can do this Please help me..



Thanks & Regards

解决方案

1.There are two property of the current thread that control the current culture:
- Thread.CurrentThread.CurrentUICulture - control the UI part
- Thread.CurrentThread.CurrentCulture - control the logic part, including the conversion of DateTime to the culture needed by the SQL server.

2.In your code, before to convert the data (DateTime, but also numerical values) that come from the UI you should convert it to DateTime value you should use the 2nd current culture property, supposing that you are set it to be the culture info needed by your logic (and your SQL server), like in the example bellow:

DateTime myDate;
DateTime.TryParse(dateStringFromUI, System.Threading.Thread.CurrentThread.CurrentCulture, DateTimeStyles.AllowWhiteSpaces, out myDate)


这篇关于如何将DateTime文化从英语转换为古吉拉特语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆