How to convert a date which is given in CCYYMMDD format to MM/DD/CCYY using C#?

假如想象 提交于 2019-12-19 11:29:41

问题


Can anyone help me to convert a date which is given in CCYYMMDD format to MM/DD/CCYY format in C#.


回答1:


Assuming by "CC" you mean century, you should just parse it and reformat it:

DateTime date = DateTime.ParseExact("yyyyMMdd", text,
                                    CultureInfo.InvariantCulture);
string newText = date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);


来源:https://stackoverflow.com/questions/6261143/how-to-convert-a-date-which-is-given-in-ccyymmdd-format-to-mm-dd-ccyy-using-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!