zoukankan      html  css  js  c++  java
  • 格式化日期字符串的自定义方法

     1 /// <summary>
     2     /// 根据系统日期,格式化日期字符串,返回的格式为20100101;
     3     /// </summary>
     4     /// <returns>返回格式化号的字符串</returns>
     5     public static string getday()
     6     {
     7         string stryear, strmonth, strday;
     8         //获取年份的字符串
     9         stryear = DateTime.Now.Year.ToString();
    10         //获取当天日期的字符串,格式是“00”
    11         if (DateTime.Now.Day.ToString().Length != 2)
    12         {
    13             strday = "0" + DateTime.Now.Day.ToString();
    14         }
    15         else
    16         {
    17             strday = DateTime.Now.Day.ToString();
    18         }
    19         //获取月份的字符串,格式是“00”月
    20         if (DateTime.Now.Month.ToString().Length != 2)
    21         {
    22             strmonth = "0" + DateTime.Now.Month.ToString();
    23         }
    24         else
    25         {
    26             strmonth = DateTime.Now.Month.ToString();
    27         }
    28         string pcode = stryear + strmonth + strday;
    29         return pcode;
    30     }
  • 相关阅读:
    JDBC MySQL 实例之 用户管理系统
    利用JDBC连接数据库(MySQL)
    CSS01
    HTML01
    GUI编程02
    GUI编程01
    名词解释
    Navicat MySQL安装
    Eclipse安装Web/JavaEE插件、Eclipse编写HTML代码
    Pascal输出星星
  • 原文地址:https://www.cnblogs.com/kdkler/p/4680518.html
Copyright © 2011-2022 走看看