帮助将多个时间和日期字符串转换为一个 [英] help converting multiple time and date strings into one
问题描述
我需要帮助将3个不同的日期和时间字符串转换为一个.请参阅我将文件中的每个项目加载到datagridview中,以便每行可能具有以下日期和时间格式之一
1.2011-10-20T20:49:59-0400
2.20:49 2011年10月20日
2009年6月15日下午8:45:30
我不是负责维护这些文件的人,但我希望现在可以,但现在我负责创建一种显示,当用户通过datagrid视图查看时间和日期时,它将统一所有内容.我知道如何转换一个字符串,但是我需要帮助,提出一种方式,当它加载信息时,如果它看到日期格式,那么它将知道将其转换为特定格式.我希望输出看起来像:2008年4月10日上午6:30:00,帮助会很大,因为我迷路了.
i need help converting 3 different date and time strings into one. See i load each item from a file into a datagridview so each line might have one of the following date and time formats
1.2011-10-20T20:49:59-0400
2.20:49 10/20/2011
3.June 15, 2009 8:45:30 PM
i wasn''t the one in charge of maintaining these file and i wish i was but now i m in charge of creating a display that will uniform everything when users are looking through the datagrid view and see the time and date. I know how to convert one string but i need help coming up with a way that when its loading the information if its sees the date format then it knows to convert it to a specific format. I want the output to look like: 4/10/2008 6:30:00 AM, help would be great because i m lost.
推荐答案
您可以使用任何stringformat 3.5或值转换器的功能
请参考这些链接..
http ://social.msdn.microsoft.com/Forums/zh-CN/wpf/thread/59e769ba-f21d-43db-9097-02558452fb52 http://karlshifflett.wordpress.com /2007/12/27/wpf-sample-series-formatting-data-binding-dates-and-numbers/ http://social.msdn.microsoft.com/论坛/en-US/wpf/thread/656ae800-1641-40a0-981a-2f1965952def [在WPF中使用管道值转换器
You could use either stringformat feauture of 3.5 or value converters
Please refer these links ..
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/59e769ba-f21d-43db-9097-02558452fb52^
http://karlshifflett.wordpress.com/2007/12/27/wpf-sample-series-formatting-data-binding-dates-and-numbers/
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/656ae800-1641-40a0-981a-2f1965952def[
Piping Value Converters in WPF
这篇关于帮助将多个时间和日期字符串转换为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!