记录......

编程入门 行业动态 更新时间:2024-10-21 07:36:49

记录......

记录......

1、将OffsetDateTime转为Date类型
Date.from(CAFxxx.current.getCurrentDateTime().toInstant());2、 /*** 对指定的date对象进行格式化:yyyy-MM-dd HH:mm:ss* @param date* @return*/public static String formateDateTime(Date date){SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String dataStr = sdf.format(date);return dataStr;}3、 /*** 对指定的date对象进行格式化:yyyy-MM-dd* @param date* @return*/public static String formateDate(Date date){SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");String dataStr = sdf.format(date);return dataStr;}4、/*** 对指定的date对象进行格式化:yyyy-MM-dd HH:mm:ss* @param date* @return*/public static String formateTime(Date date){SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");String dataStr = sdf.format(date);return dataStr;}5、/*** @param startDate 开始时间* @param endDate   结束时间* @return  两个时间之差的总小时数/总天数【带两位小数】*/public static Map getDifferHourAndDay(Date startDate, Date endDate) {Map<String,Double> map = new HashMap<>();long times = endDate.getTime() - startDate.getTime();double hours = (double) times/(60*60*1000);long day = endDate.getDay()-startDate.getDay();double days = (double) day/(1000 * 24 * 60 * 60);BigDecimal h= BigDecimal.valueOf(hours);BigDecimal d= BigDecimal.valueOf(days);double waitHours = h.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();double waitDay = d.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();map.put("waitHours",waitHours);map.put("waitDay",waitDay);return map;}6、 /*** @return 今天是本月的第几天*/public static int getDayOfMoon(){Calendar calendar = Calendar.getInstance();Date today = Date.from(CAFxxx.current.getCurrentDateTime().toInstant());calendar.setTime(today);// 此处可换为具体某一时间int monthDay = calendar.get(Calendar.DAY_OF_MONTH);return monthDay;}7、/**** @return  今天是星期几*/public static int getDayOfWeek(){Calendar calendar = Calendar.getInstance();Date today = Date.from(CAFxxx.current.getCurrentDateTime().toInstant());calendar.setTime(today);// 此处可换为具体某一时间int weekDay = calendar.get(Calendar.DAY_OF_WEEK);if (weekDay == 1) {weekDay = 7;} else {weekDay = weekDay - 1;}return weekDay;}8、/**** @param date* @return  返回指定月的天数[本月共有几天]*/public static int getDaysOfMonth(Date date) {Calendar calendar = Calendar.getInstance();calendar.setTime(date);return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);}9、/**** @return  返回当前的小时(int型 0-23)及分钟数(0-59)*/public static Map getHourAndMinOfDay(){Map<String,String> map = new HashMap<>();Date date = Date.from(CAFxxx.current.getCurrentDateTime().toInstant());Calendar calendar = Calendar.getInstance();calendar.setTime(date);map.put("hour",String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));map.put("minute", String.valueOf(calendar.get(Calendar.MINUTE)));map.put("timeDate",formateDateTime(date));return map;}10、向Oracle插入当前时间:sysdate为当前机器时间对于insert或者update语句,需要将当前时间赋值到字段中,可以使用如下函数:to_timestamp(to_char(sysdate,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS')TO_TIMESTAMP(#{yqrq}, 'YYYY-MM-DD HH24:MI:SS')11、public static String dateToString(Date date) {SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");return format.format(date);}12、public static Date string2UDate(String str) {Date date = null;SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");try {date = format.parse(str);} catch (ParseException e) {e.printStackTrace();}return date;}13、// 获取指定日期的前一天public static String getDayBefore(String specifiedDay){Calendar c = Calendar.getInstance();Date date = null;try {date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);} catch (ParseException e) {e.printStackTrace();}c.setTime(date);int day = c.get(Calendar.DATE);c.set(Calendar.DATE, day - 1);String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());return dayAfter;}14、// 获取指定日期的前一天public static Date getDateBefore(Date specifiedDate){String specifiedDay = dateToString(specifiedDate);Calendar c = Calendar.getInstance();Date date = null;try {date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);} catch (ParseException e) {e.printStackTrace();}c.setTime(date);int day = c.get(Calendar.DATE);c.set(Calendar.DATE, day - 1);String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());return string2UDate(dayAfter);}15、// 获取指定日期的后一天public static String getDayAfter(String specifiedDay) {Calendar c = Calendar.getInstance();Date date = null;try {date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);} catch (ParseException e) {e.printStackTrace();}c.setTime(date);int day = c.get(Calendar.DATE);c.set(Calendar.DATE, day + 1);String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());return dayAfter;}16、// 获取指定日期的后一天public static Date getDateAfter(Date specifiedDate) {String specifiedDay = dateToString(specifiedDate);Calendar c = Calendar.getInstance();Date date = null;try {date = new SimpleDateFormat("yy-MM-dd").parse(specifiedDay);} catch (ParseException e) {e.printStackTrace();}c.setTime(date);int day = c.get(Calendar.DATE);c.set(Calendar.DATE, day + 1);String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());return string2UDate(dayAfter);}17、// 日期去掉时分秒public static Date dateRemoveHMS(Date date){SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");String str = format.format(date);Date returnDate = null;try {returnDate = format.parse(str);}catch (ParseException e){throw new RuntimeException("Date去除时分秒转换失败");}return returnDate;}18、// Date 转换为 TimeStamppublic static Timestamp date2Timestamp(Date date){return new Timestamp(date.getTime());}19、/*** 计算日期天数差*/public static Integer daysDiff(Date startDate, Date endDate) {Temporal temporal1 = startDate.toInstant();Temporal temporal2 = endDate.toInstant();long daysDiff = ChronoUnit.DAYS.between(temporal1, temporal2);return (Integer) (int) daysDiff;}20、分组后,字段连接:postgresql:string_agg('字段名',',');mysql:group_concat(DISTINCT v ORDER BY v ASCSEPARATOR ',');21、前台生成UUID:const getuuid = () => {debugger;var s = [];var hexDigits = "0123456789abcdef";for (var i = 0; i < 36; i++) {s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);}s[14] = "4";s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);s[8] = s[13] = s[18] = s[23] = "-";var uuid = s.join("");return uuid}22、1)、首先找到一个能够正常使用重置试用天数插件(reset插件)的该公司系列的工具,例如pycharm2)、以pycharm为例,使用Everything搜索evaluation.key,找到pycharm对应的key,例如:PyCharm192.evaluation.key3)、找到IDEA版本对应的key,例如:idea212.evaluation.key4)、将PyCharm192.evaluation.key复制到IDEA的idea212.evaluation.key所在的文件夹,并将PyCharm192.evaluation.key的名称改为idea212.evaluation.key5)、此时,重新打开IDEA,就能够正常使用了23、远程桌面连接弹出“出现身份验证错误,要求的函数不受支持”=0

更多推荐

记录......

本文发布于:2023-06-28 19:56:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/932743.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!