常用的日期格式

本文通过一个C#程序示例介绍了如何使用 DateTime 类来获取当前日期和时间,并展示了多种日期时间格式化的方法,包括添加年份、天数等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 常用的时间格式
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt = DateTime.Now;
            Console.WriteLine(dt.ToString());
            Console.WriteLine("转换后的格式为:");
            Console.WriteLine("ToShortDateString" + dt.ToShortDateString());
            Console.WriteLine("ToLongDateString" + dt.ToLongDateString());
            Console.WriteLine("ToFileTime" + dt.ToFileTime().ToString());
            Console.WriteLine("ToFileTimeUtc" + dt.ToFileTimeUtc().ToString());
            Console.WriteLine("ToLocalTime" + dt.ToLocalTime().ToString());
            Console.WriteLine("ToLongDateString" + dt.ToLongDateString().ToString());
            Console.WriteLine("ToLongTimeString" + dt.ToLongTimeString().ToString());
            Console.WriteLine("ToOADate" + dt.ToOADate().ToString());
            Console.WriteLine("ToShortDateString" + dt.ToShortDateString().ToString());
            Console.WriteLine("ToShortTimeString" + dt.ToShortTimeString().ToString());
            Console.WriteLine("ToUniversalTime" + dt.ToUniversalTime().ToString());
            Console.WriteLine("Year" + dt.Year.ToString());
            Console.WriteLine("Date" + dt.Date.ToString());
            Console.WriteLine("DayOfWeek" + dt.DayOfWeek.ToString());
            Console.WriteLine("DayOfYear" + dt.DayOfYear.ToString());
            Console.WriteLine("Hour" + dt.Hour.ToString());
            Console.WriteLine("Millisecond" + dt.Millisecond.ToString());
            Console.WriteLine("Minute" + dt.Minute.ToString());
            Console.WriteLine("Month" + dt.Month.ToString());
            Console.WriteLine("Second" + dt.Second.ToString());
            Console.WriteLine("Ticks" + dt.Ticks.ToString());
            Console.WriteLine("TimeOfDay"+dt.TimeOfDay.ToString());
            Console.WriteLine("AddYears(1)"+dt.AddYears(1).ToString());
            Console.WriteLine("AddDays(1.1)"+dt.AddDays(1.1).ToString());
            Console.WriteLine("AddHours(1.1)"+dt.AddHours(1.1).ToString());
            Console.WriteLine("AddMilliseconds"+dt.AddMilliseconds(1.1).ToString());
            Console.WriteLine("AddMonths(1)"+dt.AddMonths(1).ToString());
            Console.WriteLine("AddSeconds(1.1)"+dt.AddSeconds(1.1).ToString());
            Console.WriteLine("AddMinutes(1.1)"+dt.AddMinutes(1.1).ToString());
            Console.WriteLine("AddTicks(1000)"+dt.AddTicks(1000).ToString());
            Console.WriteLine("CompareTo"+dt.CompareTo(dt).ToString());
            Console.WriteLine("Equals(2005-11-6 16:11:04)" + dt.Equals("2005-11-6 16:11:04").ToString());
            Console.WriteLine("Equals(dt)"+dt.Equals(dt).ToString());
            Console.WriteLine("GetHashCode"+dt.GetHashCode().ToString());
            Console.WriteLine("GetType"+dt.GetType().ToString()); 
            Console.WriteLine("GetTypeCode"+dt.GetTypeCode().ToString()); 
            Console.WriteLine("GetDateTimeFormats(s)[0]"+dt.GetDateTimeFormats('s')[0].ToString()); 
            Console.WriteLine("GetDateTimeFormats(t)[0]"+dt.GetDateTimeFormats('t')[0].ToString()); 
            Console.WriteLine("GetDateTimeFormats(y)[0]"+dt.GetDateTimeFormats('y')[0].ToString()); 
            Console.WriteLine("GetDateTimeFormats(D)[0]"+dt.GetDateTimeFormats('D')[0].ToString()); 
            Console.WriteLine("GetDateTimeFormats(D)[1]"+dt.GetDateTimeFormats('D')[1].ToString()); 
            Console.WriteLine("GetDateTimeFormats('D')[2]"+dt.GetDateTimeFormats('D')[2].ToString()); 
            Console.WriteLine("GetDateTimeFormats('D')[3]"+dt.GetDateTimeFormats('D')[3].ToString()); 
            Console.WriteLine("GetDateTimeFormats('M')[0]"+dt.GetDateTimeFormats('M')[0].ToString()); 
            Console.WriteLine("GetDateTimeFormats('f')[0]"+dt.GetDateTimeFormats('f')[0].ToString()); 
            Console.WriteLine("GetDateTimeFormats('g')[0]"+dt.GetDateTimeFormats('g')[0].ToString());
            Console.WriteLine("GetDateTimeFormats('r')[0]" + dt.GetDateTimeFormats('r')[0].ToString()); 
            Console.WriteLine("Format({0:d}"+string.Format("{0:d}", dt));
            Console.WriteLine("Format({0:D}" + string.Format("{0:D}", dt));
            Console.WriteLine("Format({0:f}" + string.Format("{0:f}", dt));
            Console.WriteLine("Format({0:F}" + string.Format("{0:F}", dt));
            Console.WriteLine("Format({0:g}" + string.Format("{0:g}", dt));
            Console.WriteLine("Format({0:G}" + string.Format("{0:G}", dt));
            Console.WriteLine("Format({0:M}" + string.Format("{0:M}", dt));
            Console.WriteLine("Format({0:R}" + string.Format("{0:R}", dt));
            Console.WriteLine("Format({0:s}" + string.Format("{0:s}", dt));
            Console.WriteLine("Format({0:t}" + string.Format("{0:t}", dt));
            Console.WriteLine("Format({0:T}" + string.Format("{0:T}", dt));
            Console.WriteLine("Format({0:u}" + string.Format("{0:u}", dt));
            Console.WriteLine("Format({0:U}" + string.Format("{0:U}", dt));
            Console.WriteLine("Format({0:Y}" + string.Format("{0:Y}", dt));
            Console.WriteLine("Format({0}" + string.Format("{0}", dt));
            Console.WriteLine("Format({0:yyyyMMddHHmmssffff}" + string.Format("{0:yyyyMMddHHmmssffff}", dt));
            Console.Read();
        }
    }
}
复制代码

运行结果:

内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值