日期格式造成很大问题! [英] Date format causing great problems!

查看:88
本文介绍了日期格式造成很大问题!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序从外部源导入字段

日期格式为一个柱子是英文(美国):M / d / yyyy。

所以2005年7月1日等于:7/1/05

我在应用程序的各个地方都使用这个日期。


问题是什么时候有人说葡萄牙与区域

设置的日期设置为DD-MM-YYYY。


我疯狂地想弄清楚如何让每个人都使用M / d / yyyy

计划没有改变他们的区域设置,因为很多人

根本无法做到这一点。


有人能指出我能做什么,或者发布一些关于如何围绕这个恼人的问题去寻找的代码吗?


非常感谢。


Joe

I have an application which imports fields from external source where
date format of one the collumns is English (United States): M/d/yyyy.
So July 1, 2005 equals to: 7/1/05
I am using this date everywhere in the application.

Problem is when someones is lets say in Portugal with the regional
settings for date set to DD-MM-YYYY.

I am going crazy to figure out how to make everyone to use M/d/yyyy
scheme without changing their regional settings, as lots of people
simply can''t do that.

Can someone point me to what I could do, or post some code on how to go
around this annoying problem?

It would be very much appreciated.

Joe

推荐答案



" Jozef Jarosciak" ; < jo*@doprocess.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...

"Jozef Jarosciak" <jo*@doprocess.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
我有一个从外部源导入字段的应用程序,其中一个列的日期格式为英文(美国):M / d / yyyy。
所以2005年7月1日等于: 7/1/05
我在应用程序的每个地方都使用这个日期。

问题是当某人在葡萄牙可以说具有日期设置为DD-的区域
设置时MM-YYYY。

我疯狂地想弄清楚如何让每个人都使用M / d / yyyy
方案而不改变他们的区域设置,就像很多人一样不能那样做。

有人能指出我能做什么,或者发布一些代码来解决这个烦人的问题吗?

非常感谢。

Joe
I have an application which imports fields from external source where
date format of one the collumns is English (United States): M/d/yyyy.
So July 1, 2005 equals to: 7/1/05
I am using this date everywhere in the application.

Problem is when someones is lets say in Portugal with the regional
settings for date set to DD-MM-YYYY.

I am going crazy to figure out how to make everyone to use M/d/yyyy
scheme without changing their regional settings, as lots of people
simply can''t do that.

Can someone point me to what I could do, or post some code on how to go
around this annoying problem?

It would be very much appreciated.

Joe




一种方法是检测日期是否为非美国然后做一些

转换类型。你提到外部来源。有没有

的数据来表示其国家的数据,或者至少它是非美元的b $ b?他们发回的数据类型是什么?


使用一些DateTime方法返回导入的

日期的日期。然后你可以进一步分开几小时,几分钟,一个月,如果你需要的话,每年b
。从那里你可以构建你需要的日期格式

或者可能只是在DateTime允许的情况下格式化返回的日期。


Brett



One way to is to detect if the date coming in is non US and then do some
type of transforming on it. You mention external source. Is there
something coming with the data to signify its country or at least that it is
non US? What is the data type they are sending back?

Use some of the DateTime methods to return a date against your imported
date. Then you can go further to pick it apart by hours, minutes, month,
year if you need to. From that you can construct the date format you need
or possibly just format off of the returned date if DateTime allows.

Brett


你好Brett,

我需要一个衬垫,代码可以将整个程序(窗体)设置为

" M / d月/年"因此,每当我必须处理日期时,它将忘记

关于我的用户DD-MM-YYYY格式并假设它们都具有M / d / yyyy。

有没有办法忽略区域设置及其日期格式?

Joe

Hi Brett,
I need some one liner, code which would set the whole program (form) to
"M/d/yyyy" so whenever I do have to deal with date it would forget
about my users DD-MM-YYYY format and assume they all have "M/d/yyyy".
Is there any way to ignore regional settings and its date format?
Joe




Jozef Jarosciak < jo*@doprocess.com>在消息中写道

news:11 ********************** @ g44g2000cwa.googlegr oups.com ...

"Jozef Jarosciak" <jo*@doprocess.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
你好Brett,
我需要一些衬垫,代码可以将整个程序(窗体)设置为M / d / yyyy。因此,每当我必须处理日期时,它会忘记关于我的用户DD-MM-YYYY格式并假设它们都有M / d / yyyy。
有没有办法忽略区域性设置及其日期格式?
Joe
Hi Brett,
I need some one liner, code which would set the whole program (form) to
"M/d/yyyy" so whenever I do have to deal with date it would forget
about my users DD-MM-YYYY format and assume they all have "M/d/yyyy".
Is there any way to ignore regional settings and its date format?
Joe




你有没有试过

DateTime.Parse(TextBox1.Text).ToString(" ; M / d / yyyy);


用户是否在表单中编辑此数据,或者是否导入显示为

只读给他们?


Brett



Have you tried
DateTime.Parse(TextBox1.Text).ToString("M/d/yyyy");

Are users editing this data in the form or does it appear from you import as
read only to them?

Brett


这篇关于日期格式造成很大问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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