zoukankan      html  css  js  c++  java
  • 把秒转换成分钟/返回某年某月最后一天返回时间差

    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace AIMSCommon
    {
        public class TimeParser
        {
            /// <summary>
            /// 把秒转换成分钟
            /// </summary>
            /// <returns></returns>
            public static int SecondToMinute(int Second)
            {
                decimal mm = (decimal)((decimal)Second / (decimal)60);
                return Convert.ToInt32(Math.Ceiling(mm));           
            }
    
            #region 返回某年某月最后一天
            /// <summary>
            /// 返回某年某月最后一天
            /// </summary>
            /// <param name="year">年份</param>
            /// <param name="month">月份</param>
            /// <returns>日</returns>
            public static int GetMonthLastDate(int year, int month)
            {
                DateTime lastDay = new DateTime(year, month, new System.Globalization.GregorianCalendar().GetDaysInMonth(year, month));
                int Day = lastDay.Day;
                return Day;
            }
            #endregion
    
            #region 返回时间差
            public static string DateDiff(DateTime DateTime1, DateTime DateTime2)
            {
                string dateDiff = null;
                try
                {
                    //TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
                    //TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
                    //TimeSpan ts = ts1.Subtract(ts2).Duration();
                    TimeSpan ts = DateTime2 - DateTime1;
                    if (ts.Days >=1)
                    {
                        dateDiff = DateTime1.Month.ToString() + "月" + DateTime1.Day.ToString() + "日";
                    }
                    else
                    {
                        if (ts.Hours > 1)
                        {
                            dateDiff = ts.Hours.ToString() + "小时前";
                        }
                        else
                        {
                            dateDiff = ts.Minutes.ToString() + "分钟前";
                        }
                    }
                }
                catch
                { }
                return dateDiff;
            }
            #endregion
        }
    }
    
  • 相关阅读:
    DFT
    BSDL
    穆尼里奥:未派上最好点球手;齐达内成功并不意外
    module使用和设置
    APU (美国AMD公司研发的加速处理器)
    Lucio: We avoided Mourinho after every loss
    高位压迫——萨基给世界足坛带来的技术革命
    穆里尼奥:曼联没有在今夏尝试过签下C罗
    Linux 的 Out-of-Memory (OOM) Killer
    shell source命令说明
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5661096.html
Copyright © 2011-2022 走看看