如何替换特殊字符的日期时间格式 [英] how to replace special characters date time format

查看:217
本文介绍了如何替换特殊字符的日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友

如何在vb.net中以日期时间格式替换specail charecters(/,\,:,<,>)



谢谢

dear friends
how to replace specail charecters (/,\,:,<,>) in datetime format in vb.net

thanks

推荐答案

您可以使用RegEx,也可以使用String.Replace()来执行此操作。如果您不熟悉其中任何一个,那么您可以谷歌搜索示例。



但通常您不想从日期中删除字符,因此您可能需要重新考虑您的策略。
You can use RegEx or you can use String.Replace() to do it. If you are unfamiliar with either one then you can google for examples.

But normally you will not want to strip characters from dates so you may need to rethink your strategy.


首先: 日期是日期 而且没别的!



其次,如果你想以自定义格式显示 date ,请看这里:自定义日期和时间格式字符串 [ ^ ]



First of all: date is date and nothing else!

Second of all, if you want to display date in custom format, please have a look here: Custom Date and Time Format Strings[^]

Dim thisDate1 As Date = #6/10/2011#
Console.WriteLine("Date: {0} is displayed as: {1}", thisDate1,thisDate1.ToString("ddMMMyyyy") )





结果:



Result:

Date: 2011-06-10 00:00:00 is displayed as: 10Jun2011


这篇关于如何替换特殊字符的日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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