zoukankan
html css js c++ java
asp.net 处理和计算微博发布时间
using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace MicroBlogForWP7.Classes { 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(double.Parse(mm.ToString()))); } #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 #region 返回该微博是什么时候发的 /// <summary> /// 返回该微博是什么时候发的 /// </summary> /// <param name="year">发微博时间</param> /// <param name="month">当前时间</param> public static string GetWhenSendTime(DateTime BlogTime, DateTime NowTime) { DateTime t1 = BlogTime; DateTime t2 = NowTime; string RES = ""; if ((t2 - t1).TotalMinutes > 1440) { RES = t1.ToString("yyyy年MM月dd日 HH:mm"); } else if ((t2 - t1).TotalMinutes > 60) { RES = Math.Floor(((t2 - t1).TotalMinutes / 60)).ToString() + "小时" + (Math.Floor((t2 - t1).TotalMinutes) % 60).ToString() + "分钟前"; } else { if ((Math.Floor((t2 - t1).TotalMinutes) % 60) <= 0) RES = "刚刚更新"; else RES = (Math.Floor((t2 - t1).TotalMinutes) % 60).ToString() + "分钟前"; } return RES; } #endregion } }
查看全文
相关阅读:
ASP.NET MVC 页面重定向
Linux用户管理
linux开机、重启和用户注销
vi和vim
Mac 与 Linux服务器上传下载
linux 文件体系
linux 常用命令及异常处理
单独使用ueditor的图片上传功能,同时获得上传图片地址和缩略图
mybatis oracle 插入自增记录 获取主键值 写回map参数
MyBatis SpringMVC映射配置注意
原文地址:https://www.cnblogs.com/javawebsoa/p/2458103.html
最新文章
java中静态代码块,构造代码块,以及构造方法的执行顺序
关于$.fn.*的使用
centos7安装 mysql数据库
centos7 安装jdk7
CentOS 安装rz和sz命令
Mybatis之关联查询
注解式开发spring定时器
JVM调优总结
Java的in.nextInt()和in.nextLine()方法的具体内涵
Java之Swing体系——制作自己的登录界面
热门文章
Java之类的继承
验证哥德巴赫猜想(好难啊,感觉自己写的有点啰嗦,求大神指点!!!)
C++:函数求数根(总算写出来了。。。。)
C++:补齐函数编写递归函数计算x的y次幂(hhhh函数 !头疼!)
C++:利用如下公式,编写函数计算∏的值,直到最后一项的绝对值小于e,主程序接收从键盘输入的e,输出∏的值(保留5位小数)。 ∏/4 = 1-1/3+1/5-1/7...
C++:输入n个数,通过气泡法从小到大排列顺序(掌握不熟,还请谅解)
C++:函数求阶乘(如有不好之处还请谅解)
我的编程开始啦!!!!!!!!!
Linux组管理和权限管理
Linux实用指令
Copyright © 2011-2022 走看看