package cn.com.dekn.common.util; import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; public class DateUtil { public static Timestamp getNowTime() { return new Timestamp(System.currentTimeMillis()); } public static String getYear() { SimpleDateFormat date = new SimpleDateFormat("yy"); return date.format(new Date()); } public static String getYearYYYY() { SimpleDateFormat date = new SimpleDateFormat("yyyy"); return date.format(new Date()); } public static String getMonth() { SimpleDateFormat date = new SimpleDateFormat("MM"); return date.format(new Date()); } public static String getDay() { SimpleDateFormat date = new SimpleDateFormat("dd"); return date.format(new Date()); } public static String getHour() { SimpleDateFormat date = new SimpleDateFormat("HH"); return date.format(new Date()); } public static String getMinute() { SimpleDateFormat date = new SimpleDateFormat("mm"); return date.format(new Date()); } public static String getSecond() { SimpleDateFormat date = new SimpleDateFormat("ss"); return date.format(new Date()); } public static String getMillisecond() { SimpleDateFormat date = new SimpleDateFormat("SSS"); return date.format(new Date()); } public static boolean isToday(Timestamp time) { SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd"); if (format.format(time).equals(format.format(new Date()))) { return true; } return false; } public static String getCurrentDay(String dateFormat) { SimpleDateFormat format = new SimpleDateFormat(dateFormat); return format.format(new Date()); } public static long getDayBetween(String now, String fore) { long count = 0L; SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); try { Date nowDate = myFormatter.parse(now); Date foreDate = myFormatter.parse(fore); count = (nowDate.getTime() - foreDate.getTime()) / 86400000L; } catch (ParseException e) { count = 0L; e.printStackTrace(); } return count; } public static Timestamp getTodayTimestamp() { String nowDateStr = getCurrentDay("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Timestamp timestamp = null; try { timestamp = new Timestamp(sdf.parse(nowDateStr).getTime()); } catch (ParseException e) { e.printStackTrace(); } return timestamp; } public static Timestamp rollDayTimestamp(String dateStr, int amount) { String nowDate = dateStr; if ((nowDate == null) || (nowDate.trim().equals(""))) { nowDate = getCurrentDay("yyyy-MM-dd"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar nowCalendar = Calendar.getInstance(); try { nowCalendar.setTime(sdf.parse(nowDate)); } catch (ParseException e) { e.printStackTrace(); } nowCalendar.add(5, amount); Timestamp timestamp = new Timestamp(nowCalendar.getTimeInMillis()); return timestamp; } public static Timestamp rollMonthTimestamp(String dateStr, int amount) { String nowDate = dateStr; if ((nowDate == null) || (nowDate.trim().equals(""))) { nowDate = getCurrentDay("yyyy-MM-dd"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar nowCalendar = Calendar.getInstance(); try { nowCalendar.setTime(sdf.parse(nowDate)); } catch (ParseException e) { e.printStackTrace(); } nowCalendar.add(2, amount); Timestamp timestamp = new Timestamp(nowCalendar.getTimeInMillis()); return timestamp; } public static String format(Timestamp time, String formatStr) { if (time == null) { return null; } SimpleDateFormat format = new SimpleDateFormat(formatStr); String date = format.format(time); return date; } public static String format(String time, String formatStr) { if (StrUtil.isNull(time)) { return null; } String date = ""; try { SimpleDateFormat format = new SimpleDateFormat(formatStr); date = format.format(new Timestamp(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time).getTime())); } catch (ParseException e) { e.printStackTrace(); return ""; } return date; } public static String getMonthStr(int month) { String monthStr = ""; switch (month) { case 1: monthStr = "一月"; break; case 2: monthStr = "二月"; break; case 3: monthStr = "三月"; break; case 4: monthStr = "四月"; break; case 5: monthStr = "五月"; break; case 6: monthStr = "六月"; break; case 7: monthStr = "七月"; break; case 8: monthStr = "八月"; break; case 9: monthStr = "九月"; break; case 10: monthStr = "十月"; break; case 11: monthStr = "十一月"; break; case 12: monthStr = "十二月"; } return monthStr; } public static int getWeekOfYear() { int week = 0; Calendar c = Calendar.getInstance(); week = c.get(3); return week; } public static String getStartDate(int year, int weekNo) { Calendar cal = Calendar.getInstance(); cal.set(1, year); cal.set(3, weekNo); cal.set(7, 2); SimpleDateFormat returnDate = new SimpleDateFormat("yyyy年MM月dd日"); return returnDate.format(cal.getTime()); } public static String getEndDate(int year, int weekNo) { Calendar cal = Calendar.getInstance(); cal.set(1, year); cal.set(3, weekNo + 1); cal.set(7, 1); SimpleDateFormat returnDate = new SimpleDateFormat("yyyy年MM月dd日"); return returnDate.format(cal.getTime()); } public static Collection getTwoDateDayList(String endDate, String beginDate) { Collection resultList = new ArrayList(); long dayCount = getDayBetween(endDate, beginDate); resultList.add(beginDate); for (int i = 0; i < dayCount; i++) { Timestamp now = rollDayTimestamp(beginDate, 1); beginDate = format(now, "yyyy-MM-dd"); resultList.add(beginDate); } return resultList; } public static Collection getTwoDateDayListDesc(String endDate, String beginDate) { Collection resultList = new ArrayList(); long dayCount = getDayBetween(endDate, beginDate); resultList.add(endDate); for (long i = dayCount; i > 0L; i -= 1L) { Timestamp now = rollDayTimestamp(endDate, -1); endDate = format(now, "yyyy-MM-dd"); resultList.add(endDate); } return resultList; } public static String getWeekForDate(String date, String format) { String week = ""; SimpleDateFormat f1 = new SimpleDateFormat(format); Date d = null; try { d = f1.parse(date); } catch (ParseException e) { e.printStackTrace(); } SimpleDateFormat formatter = new SimpleDateFormat("E"); week = formatter.format(d); return week; } public static String getStandardDate(int year, int month, int day) { String yearStr = String.valueOf(year); String monthStr = String.valueOf(month); String dayStr = String.valueOf(day); if (month < 10) { monthStr = "0" + month; } if (day < 10) { dayStr = "0" + day; } return yearStr + "-" + monthStr + "-" + dayStr; } public static String rollHoursTimestamp(String dateStr, String amount) { SimpleDateFormat sdf = new SimpleDateFormat(dateStr); String timeStr = getCurrentDay(dateStr); Date time = null; try { time = sdf.parse(timeStr); } catch (ParseException e) { e.printStackTrace(); } int hours = StrUtil.getNotNullIntValue(amount, 0); Date torollHours = new Date(time.getTime() - hours * 3600 * 1000); return sdf.format(torollHours).toString(); } public static String rollMinutesTimestamp(String dateStr, String amount) { SimpleDateFormat sdf = new SimpleDateFormat(dateStr); String timeStr = getCurrentDay(dateStr); Date time = null; try { time = sdf.parse(timeStr); } catch (ParseException e) { e.printStackTrace(); } int minutes = StrUtil.getNotNullIntValue(amount, 0); Date torollMinutes = new Date(time.getTime() - minutes * 60 * 1000); return sdf.format(torollMinutes).toString(); } public static boolean compareTotime(String dateStr) { boolean isOK = false; long count = 0L; SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String nowtimeStr = getCurrentDay("yyyy-MM-dd HH:mm:ss"); try { Date nowDate = myFormatter.parse(nowtimeStr); Date foreDate = myFormatter.parse(dateStr); count = nowDate.getTime() - foreDate.getTime(); } catch (ParseException e) { count = 0L; e.printStackTrace(); } if (count > 0L) { isOK = true; } return isOK; } public static boolean compareTotime(String oneStr, String twoStr) { boolean isOK = false; long count = 0L; SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date nowDate = myFormatter.parse(oneStr); Date foreDate = myFormatter.parse(twoStr); count = nowDate.getTime() - foreDate.getTime(); } catch (ParseException e) { count = 0L; e.printStackTrace(); } if (count > 0L) { isOK = true; } return isOK; } public static Timestamp getNotNullTimestampValue(String data, String dateFormat) { Timestamp value; try { Timestamp value; if ((data == null) || (data.equals(""))) { value = new Timestamp(System.currentTimeMillis()); } else { SimpleDateFormat smd = new SimpleDateFormat(dateFormat); value = new Timestamp(smd.parse(data).getTime()); } } catch (Exception e) { Timestamp value; e.printStackTrace(); value = new Timestamp(System.currentTimeMillis()); } return value; } public static int compareTimstampStr(String sourceStr, String destStr, String formartStr) { int result = 10; SimpleDateFormat dateFormatter = new SimpleDateFormat(formartStr); long temp = 10L; try { Date beginDate = dateFormatter.parse(sourceStr); Date endDate = dateFormatter.parse(destStr); temp = beginDate.getTime() - endDate.getTime(); } catch (ParseException e) { result = 2147483647; e.printStackTrace(); } if (temp > 0L) result = 1; else if (temp == 0L) result = 0; else if (temp < 0L) { result = -1; } return result; } public static String getDateFormat(String date) { Timestamp nowDay = getTodayTimestamp(); String hour = date.substring(11, date.length()); date = format(date, "yyyy-MM-dd"); if (date.equals(getCurrentDay("yyyy-MM-dd"))) { return hour; } if (nowDay.equals(rollDayTimestamp(date, 1))) { return "昨天 " + hour; } if (nowDay.equals(rollDayTimestamp(date, 2))) { return "前天 " + hour; } return date + " " + hour; } public static int[] getDayBetweenForYMD(String endDate, String beginDate) { int endDateY = Integer.parseInt(format(endDate, "yyyy", "yyyy-MM-dd")); int endDateM = Integer.parseInt(format(endDate, "MM", "yyyy-MM-dd")); int endDateD = Integer.parseInt(format(endDate, "dd", "yyyy-MM-dd")); int beginDateY = Integer.parseInt(format(beginDate, "yyyy", "yyyy-MM-dd")); int beginDateM = Integer.parseInt(format(beginDate, "MM", "yyyy-MM-dd")); int beginDateD = Integer.parseInt(format(beginDate, "dd", "yyyy-MM-dd")); int mS = (endDateY - beginDateY) * 12 + endDateM - beginDateM; int y = mS / 12; int m = mS % 12; int d = (int)getDayBetween(getStandardDate(endDateY, endDateM, endDateD), getStandardDate(endDateY, endDateM, beginDateD)); if (d < 0) { m--; d += getMonthLastDay(endDateY, endDateM - 1); } if (m < 0) { y--; m += 12; } return new int[] { y, m, d }; } public static int getMonthLastDay(int year, int month) { Calendar a = Calendar.getInstance(); a.set(1, year); a.set(2, month - 1); a.set(5, 1); a.roll(5, -1); int maxDate = a.get(5); return maxDate; } public static String format(String time, String formatStr, String timeformatStr) { if (StrUtil.isNull(time)) { return null; } String date = ""; try { SimpleDateFormat format = new SimpleDateFormat(formatStr); date = format.format(new Timestamp(new SimpleDateFormat(timeformatStr).parse(time).getTime())); } catch (ParseException e) { e.printStackTrace(); return ""; } return date; } public static boolean checkDate(String date, String format) { SimpleDateFormat df = new SimpleDateFormat(format); Date d = null; try { d = df.parse(date); } catch (Exception e) { return false; } String s1 = df.format(d); return date.equals(s1); } }
例如:
public Timestamp getCONFIRM_TIME() { return CONFIRM_TIME; } public String getConfirmTime(String format){ return DateUtil.format(this.getCONFIRM_TIME(), format); } public void setCONFIRM_TIME(Timestamp cONFIRM_TIME) { CONFIRM_TIME = cONFIRM_TIME; }
在实体类里面添加个String方法Timestamp就可以转String了 format是时间格式,如:
jsonNew.put("delivery_time", order.getDeliveryTime("yyyy-MM-dd HH:mm:ss")); jsonNew.put("confirm_time", order.getConfirmTime("yyyy-MM-dd HH:mm:ss"));
相关推荐
《永磁无刷直流电机控制系统与软件综合研究——集成电机计算软件、电机控制器及电磁设计软件的创新设计与实践》,永磁无刷直流电机计算与控制软件:高效电机控制器与电磁设计工具,永磁无刷直流电机计算软件,电机控制器,无刷电机设计软件,电机电磁设计软件 ,永磁无刷直流电机计算软件; 电机控制器; 无刷电机设计软件; 电机电磁设计软件,无刷电机设计专家:永磁无刷直流电机计算与控制器设计软件
新能源汽车VCU开发模型及策略详解:从控制策略到软件设计全面解析,新能源汽车VCU开发模型及策略详解:从控制策略到软件设计全面解析,新能源汽车VCU开发模型及控制策略,MBD电控开发 新能源汽车大势所向,紧缺VCU电控开发工程师,特别是涉及新能源三电系统,工资仅仅低于无人驾驶、智能驾驶岗位。 ——含控制策略模型 整车控制策略详细文档 通讯协议文档 接口定义 软件设计说明文档 等(超详细,看懂VCU电控策略开发就通了) 内容如下: 新能源汽车整车控制器VCU学习模型,适用于初学者。 1、模型包含高压上下电,行驶模式管理,能量回馈,充电模式管理,附件管理,远程控制,诊断辅助功能。 2、软件说明书(控制策略说明书) 3、模型有部分中文注释 对想着手或刚开始学习整车控制器自动代码生成或刚接触整车控制器有很大帮助。 ,新能源汽车VCU开发模型; 控制策略; MBD电控开发; 模型学习; 代码生成; 整车控制器; 能量回馈; 诊断辅助功能,新能源汽车电控开发详解:VCU控制策略模型及学习手册
内容概要:本文详细介绍了两种利用 Python 读取 Excel 文件的不同方法,分别是基于 pandas 和 openpyxl。对于想要利用Python 处理 Excel 数据的读者来说,文中不仅提供了简洁明了的具体代码片段以及执行效果展示,还针对每个库的应用特性进行了深度解析。此外,文档提到了一些进阶应用技巧如只读特定的工作薄、过滤某些列等,同时强调了需要注意的地方(像是路径设置、engine 参数调整之类),让读者可以在面对实际项目需求时做出更加明智的选择和技术选型。 适合人群:对 Python 有基本掌握并希望提升数据读取能力的开发人员。 使用场景及目标:适用于任何涉及到批量数据导入或是与 Excel 进行交互的业务流程。无论是做初步的数据探索还是深入挖掘隐藏于电子表格背后的故事,亦或是仅为了简化日常办公自动化任务都可以从中受益。最终目标帮助使用者熟悉两大主流 Excel 解决方案的技术特性和最佳实践。 阅读建议:本文既是一份详尽的学习指南也是一份方便随时查阅的手册。因此初学者应当认真研究所提供的示例,而有一定经验者也可以快速定位到感兴趣的部分查看关键要点。
# 医护人员排班系统 ## 1. 项目介绍 本系统是一个基于SpringBoot框架开发的医护人员排班管理系统,用于医院管理医护人员的排班、调班等工作。系统提供了完整的排班管理功能,包括科室管理、人员管理、排班规则配置、自动排班等功能。 ## 2. 系统功能模块 ### 2.1 基础信息管理 - 科室信息管理:维护医院各科室基本信息 - 医护人员管理:管理医生、护士等医护人员信息 - 排班类型管理:配置不同的排班类型(如:早班、中班、晚班等) ### 2.2 排班管理 - 排班规则配置:设置各科室排班规则 - 自动排班:根据规则自动生成排班计划 - 排班调整:手动调整排班计划 - 排班查询:查看各科室排班情况 ### 2.3 系统管理 - 用户管理:管理系统用户 - 角色权限:配置不同角色的操作权限 - 系统设置:管理系统基础配置 ## 3. 技术架构 ### 3.1 开发环境 - JDK 1.8 - Maven 3.6 - MySQL 5.7 - SpringBoot 2.2.2 ### 3.2 技术栈 - 后端框架:SpringBoot - 持久层:MyBatis-Plus - 数据库:MySQL - 前端框架:Vue.js - 权限管理:Spring Security ## 4. 数据库设计 主要数据表: - 科室信息表(keshixinxi) - 医护人员表(yihurengyuan) - 排班类型表(paibanleixing) - 排班信息表(paibanxinxi) - 用户表(user) ## 5. 部署说明 ### 5.1 环境要求 - JDK 1.8+ - MySQL 5.7+ - Maven 3.6+ ### 5.2 部署步骤 1. 创建数据库并导入SQL脚本 2. 修改application.yml中的数据库配置 3. 执行maven打包命令:mvn clean package 4. 运行jar包:java -jar xxx.jar ## 6. 使用说明 ### 6.1 系统登录 - 管理员账号:admin - 初始密码:admin ### 6.2 基本操作流程 1. 维护基础信息(科室、人员等) 2. 配置排班规则 3. 生成排班计划 4. 查看和调整排班 ## 7. 注意事项 1. 首次使用请及时修改管理员密码 2. 定期备份数据库 3. 建议定期检查和优化排班规则
MATLAB仿真的夫琅禾费衍射强度图:圆孔、圆环、矩形孔定制研究,MATLAB仿真:夫琅禾费衍射强度图的可定制性——以圆孔、圆环及矩形孔为例的研究分析,MATLAB夫琅禾费衍射强度图仿真 圆孔,圆环,矩形孔可定制。 ,MATLAB; 夫琅禾费衍射; 强度图仿真; 圆孔; 圆环; 矩形孔; 可定制。,MATLAB仿真夫琅禾费衍射强度图:定制孔型(圆孔/圆环/矩形)
详细介绍及样例数据:https://blog.csdn.net/samLi0620/article/details/145652300
基于Dugoff轮胎模型与B08_01基础建模的七自由度车辆动力学模型验证:利用MATLAB 2018及以上版本与CarSim 2020.0软件的仿真对比研究,基于Dugoff轮胎模型与B08_01框架的七自由度车辆动力学模型验证——使用MATLAB 2018及以上版本与CarSim 2020.0软件进行仿真对比研究,七自由度车辆动力学模型验证(Dugoff轮胎模型,B08_01基础上建模) 1.软件: MATLAB 2018以上;CarSim 2020.0 2.介绍: 基于Dugoff轮胎模型和车身动力学公式,搭建7DOF车辆动力学Simulink模型,对相关变量(质心侧偏角,横摆角速度,纵、横向速度及加速度)进行CarSim对比验证。 ,核心关键词:七自由度车辆动力学模型验证; Dugoff轮胎模型; B08_01建模基础; MATLAB 2018以上; CarSim 2020.0; Simulink模型; 变量对比验证。,基于Dugoff轮胎模型的七自由度车辆动力学模型验证与CarSim对比
【毕业设计】基于Java+servlet+jsp+css+js+mysql实现“转赚”二手交易平台_pgj
微猫恋爱聊妹术小程序源码介绍: 微猫恋爱聊妹术小程序源码是一款全新升级的聊天工具,它采用全新主题和UI,完美支持分享朋友圈功能。同时,它的独立后台也进行了大规模更新,让操作更加简单。其中,课堂页面、搜索页面和子话术列表页面等,均增加了流量主展示,具有超多的功能。 安装教程: 您可以先加入微猫恋爱聊妹术小程序源码的赞助群,然后在群内找到魔方安装说明。根据源码编号找到相应的安装说明,非常详细,让您轻松完成安装。
电气安装工程安全技术规程_蒋凯,杨华甫,马仲范,王清禄译;孙照森校;鞍钢工程技术编委会编
基于Copula函数的风光空间相关性联合场景生成与K-means聚类削减MATLAB研究,基于Copula函数的风光空间相关性联合场景生成与K-means聚类削减算法研究,基于copula的风光联合场景生成?K-means聚类并削减 MATLAB 由于目前大多数研究的是不计风光出力之间的相关性影响,但是地理位置相近的风电机组和光伏机组具有极大的相关性。 因此,采用 Copula 函数作为风电、光伏联合概率分布,生成风、光考虑空间相关性联合出力场景,在此基础上,基于Kmeans算法,分别对风光场景进行聚类,从而实现大规模场景的削减,削减到5个场景,最后得出每个场景的概率与每个对应场景相乘求和得到不确定性出力 ,基于Copula的风光联合场景生成; K-means聚类削减; 空间相关性; 概率分布; 场景削减,基于Copula与K-means的风光联合场景生成与削减研究
模块化多电平变流器MMC的VSG控制技术研究:基于MATLAB-Simulink的仿真分析与定制实现——支持三相与任意电平数,构网型模块化多电平变流器MMC的VSG控制策略与仿真模型:三相负荷变动下的虚拟同步发电机控制研究,构网型 模块化多电平变流器 MMC 的VSG控制 同步发电机控制 MATLAB–Simulink仿真模型,可按需求定制 10电平.14电平,任意电平可做。 三相MMC,采用VSG控制。 设置负荷变动,调整有功无功,保持电网电压和频率 ,构网型模块化多电平变流器; MMC的VSG控制; 虚拟同步发电机控制; MATLAB–Simulink仿真模型; 任意电平可做; 三相MMC; 负荷变动; 有功无功调整; 电网电压和频率保持。,基于VSG控制的模块化多电平变流器(MMC)的构网型仿真模型
暗通道算法DCP-Python实现
南师大实验室安全准入知识供学习
纯openMV寻迹小车.zip
【毕业设计】基于Java mvc架构开发的完整购物网站
以下是针对初学者的 **51单片机入门教程**,内容涵盖基础概念、开发环境搭建、编程实践及常见应用示例,帮助你快速上手。
springboot医院信管系统--
springboot私人健身与教练预约管理系统--
yolov8-0的资源