Datetime. tostring ("yyyymmddhhmmss ")

Source: Internet
Author: User
Someone asked me in the group... write it for a try .... 1 Using System;
2 Using System. Collections. Generic;
3 Using System. text;
4
5 Namespace Xiao
6 {
7 /**/ /// <Summary>
8///Create by Huang Lin Feng
9/// </Summary>
10 Class Program
11 {
12 Static   Void Main ( String [] ARGs)
13 {
14 Try
15 {
16 Datetime D;
17 Datetime dnow;
18 Dnow = System. datetime. now;
19 String Strdatetime = Dnow. tostring ( " Yyyymmddhhmmss " );
20 Console. writeline ( " Current Time (displayed normally ): "   + Dnow. tostring ( " Yyyy mm dd hh mm SS seconds " ));
21 Console. writeline ( " Current Time: " + Strdatetime );
22 D = Datetime. parseexact (strdatetime, " Yyyymmddhhmmss " , System. Globalization. cultureinfo. currentculture );
23 Console. writeline ( " Conversion time (displayed normally ): " + D. tostring ( " Yyyy mm dd hh mm SS seconds " ));
24 Console. writeline ( " Conversion time: "   + D. tostring ( " Yyyymmddhhmmss " ));
25 }
26 Catch (Exception exp)
27 {
28System. Console. writeline (exp. Message );
29}
30 }
31 }
32 }

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.