开发者

C#: How to convert string to Julian date accordingly to the giver format?

开发者 https://www.devze.com 2023-01-29 08:10 出处:网络
开发者_运维百科my question is how to convert input DateTime value into Julian date format but the result should be in the format \"0YYDDD\"? I suppose January, 2nd 2011 should look like \"011002\".
开发者_运维百科

my question is how to convert input DateTime value into Julian date format but the result should be in the format "0YYDDD"? I suppose January, 2nd 2011 should look like "011002".

Thanks


DateTime dt = new DateTime(2011, 1, 2);
Console.WriteLine( String.Format("{0:0yy0dd}",dt) );

A good cheatsheet can be found here.


Alternatively:

julianFormatString = "0" + (dateTimeVar.Year % 100).ToString() + "0" + dateTimeVar.Day.ToString();
0

精彩评论

暂无评论...
验证码 换一张
取 消