English 中文(简体)
正在删除日期时间的时区 。
原标题:Removing Timezone for DateTime.ParseExact

我试图用以下格式将字符串解析成日期时间:

[日],[日期][月][年][时间][上午/下午][时区](例如:)

"2011年12月1日,星期四,上午8: 30,下午8:

我用“ DateTime” 来做这个。 使用格式分析( “ dddd, dd MM yyyyy hh:mmtt” ) 格式。 但是, Timmzone 给了我一个问题。 没有用于读取以这种方式写成的时区代码 。 我不管时间区, 所以我想把它删掉或者读读它 - 只要异性性行为有效。

去除它的一种方法是将它从字符串中(使用.replace)实际删除(使用.replace)——然而我不知道源代码将产生多少个不同的时区,反正我认为长长的替换线看起来丑陋且容易出错。

难道有办法去掉它,或阅读它吗?

最佳回答

您可以扫描字符串中的空格, 并在第五个空格之后切除所有空格。 如果只有四个空格, 请保留整个字符串( 这意味着没有时区 ) 。

本答复是在>Jon 的评论后编辑的。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签