How datetime in C # resolves a two-digit year

Source: Internet
Author: User
Tags string format

First Spray one. This is the demand--the year in which two digits are converted to four- digit years. Brain. Who gave birth to the two-digit number that came out. Think with your toes and know that the end result is not unique (not the only thing that doesn't solve the problem). The brain was eroded by the millennium bug.

For this demand, directly printed on the "INVALID", where to go back to where.

Answer:

If a string format that represents a date is similar to "YYYY-MM-DD", that is, the year is represented by four digits , then the year that datetime resolves is the year we see.
For example: "2014-06-19" resolved the year was 2014.


If the year in the original string is represented by a two-digit number, that is, the format is similar to "YY-MM-DD", what is the century of datetime parsing?
such as: "14-06-19" Resolution of the Year is 1914. 2014. 2114. ...
By default, this is determined by the operating system settings that run the program.

(In fact, not just C #, many other languages or programs use this approach.) )


Win7 as an example:




Note: The Year "1930" and "2029" set in the previous illustration will change over time.

Such as: this year (2014) is "1930" and "2029", to the next year (2015) will automatically become "1931" and "2030".

Directive Size: 77.7 KB Size: KB View picture attachments

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.