当前位置: 首页 > news >正文

苏州新区保洁公司广州 关于进一步优化

苏州新区保洁公司,广州 关于进一步优化,有没有做网站的博士专业,如何制作免费网站flutter开发实战-时间显示刚刚几分钟前几小时前 在开发中经常遇到从服务端获取的时间戳,需要转换显示刚刚、几分钟前、几小时前、几天前、年月日等格式。 一、代码实现 static String timeFormatterChatTimeStamp(int seconds) {try {int nowDateSeconds (DateTi…

flutter开发实战-时间显示刚刚几分钟前几小时前

在开发中经常遇到从服务端获取的时间戳,需要转换显示刚刚、几分钟前、几小时前、几天前、年月日等格式。

一、代码实现

static String timeFormatterChatTimeStamp(int seconds) {try {int nowDateSeconds =(DateTime.now().millisecondsSinceEpoch / 1000).truncate();String anotherDate =DateUtil.formatDateMs(seconds*1000, format: DateFormats.full);String nowDate =DateUtil.formatDateMs(nowDateSeconds*1000, format: DateFormats.full);print("timeFormatterChatTimeStamp ""seconds:${seconds},""nowDateSeconds:${nowDateSeconds},""anotherDate:${anotherDate},""nowDate:${nowDate}");//为了判断当前时间是否为未来时间if (seconds > nowDateSeconds) {return anotherDate;}List<String> anotherDateList = anotherDate.split(" ");List<String> nowDateList = nowDate.split(" ");if (anotherDateList.length == 2 && nowDateList.length == 2) {String nowDateYMD = nowDateList[0];String nowDateHMS = nowDateList[1];String anotherDateYMD = anotherDateList[0];String anotherDateHMS = anotherDateList[1];List<String> anotherDateYMDList = anotherDateYMD.split("-");List<String> nowDateYMDList = nowDateYMD.split("-");List<String> anotherDateHMSList = anotherDateHMS.split(":");List<String> nowDateHMSList = nowDateHMS.split(":");String anotherDateY = anotherDateYMDList[0];String anotherDateM = anotherDateYMDList[1];String anotherDateD = anotherDateYMDList[2];String nowDateY = nowDateYMDList[0];String nowDateM = nowDateYMDList[1];String nowDateD = nowDateYMDList[2];String anotherDateH = anotherDateHMSList[0];String anotherDateMi = anotherDateHMSList[1];String anotherDateS = anotherDateHMSList[2];int year = int.parse(anotherDateY) - int.parse(nowDateY);if (year < 0) {// 过去(今年以前)return "${anotherDateY}${anotherDateM}${anotherDateD}${anotherDateH}:${anotherDateMi}";} else {if (nowDateY == anotherDateY) {// 今年return "${anotherDateM}${anotherDateD}${anotherDateH}:${anotherDateMi}";} else {return "${anotherDateY}${anotherDateM}${anotherDateD}${anotherDateH}:${anotherDateMi}";}}} else {return anotherDate;}} catch (e) {return "${seconds}";}}

二、小结
flutter开发实战-格式化时间显示刚刚几分钟前几小时前等

从服务端获取的时间戳,需要转换显示刚刚、几分钟前、几小时前、几天前、年月日等格式。用到了DateUtil。

学习记录,每天不停进步。

http://www.ritt.cn/news/19264.html

相关文章:

  • 网站开发的阶段流程图链接怎么做
  • 网络规划设计师知识点杭州seo按天计费
  • 网站建设收费标准新闻win10必做的优化
  • 新闻网站网络安全建设搜索引擎最新排名
  • 广州vi设计公司淘宝seo是什么意思
  • 南阳做网站多少电话最近新闻内容
  • 祝贺网站上线网站的宣传推广方式
  • html5手机网站欣赏小吃培训机构排名前十
  • 响应式网站的优点网站制作公司怎么找
  • 专业做网文的网站百度账号申请注册
  • 供应优惠的小企业网站建设网络营销策划论文
  • 手机wap版网站制作阳江seo
  • 常德网站建设网站网站seo优化技巧
  • 网站到期请续费西安百度推广网站建设
  • 长春品牌网站建设公司免费发广告的软件
  • 响应式网站的缺点如何在网上推广产品
  • 嘉兴做网站多少钱百度建一个网站多少钱
  • 无锡网站建设人员应用商店下载
  • 饰品网站设计方案汕头seo外包机构
  • wordpress post grid百度关键词相关性优化软件
  • 白石洲附近做网站公司网站宣传文案
  • 做外贸需要有自己的网站吗软文发稿平台有哪些
  • 北京搬家公司哪家好站长工具seo排名查询
  • 发簪做的比较好的网站百度云链接
  • 全新域名请收藏seo人员工作内容
  • 网站开发 职位描述资源网站优化排名软件公司
  • 网站建设小程序常用的搜索引擎
  • 莱州双语网站论文收录网站有哪些
  • 精品成品冈站源码免费北京seo运营推广
  • 自己做投票网站怎么弄西安危机公关公司