package com.specl.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateUtil {
private static final SimpleDateFormat shortsdf = new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat longsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 时间格式化(到日期)
*
* @param date
* @return
*/
public static String formatDate(Date date) {
String newDate = "";
if (date == null)
return newDate;
try {
newDate = shortsdf.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return newDate;
}
/**
* 时间格式化(到秒)
*
* @param obj
* @return
*/
public static String formatTime(Date date) {
String newDate = "";
if (date == null)
return newDate;
try {
newDate = longsdf.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return newDate;
}
/**
* 时间格式化(到秒)
*
* @param ticks 时间刻度
* @return
*/
public static String formatTime(Long ticks) {
String newDate = "";
if (ticks == null)
return newDate;
try {
Date date=new Date(ticks);
newDate = longsdf.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return newDate;
}
public static String formatTimeMin(Date date) {
String newDate = "";
if (date == null)
return newDate;
try {
newDate = shortsdf.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return newDate;
}
public static Date string2Date(String s, int type) {
if (s == null) {
return null;
}
Calendar cal = null;
String a[] = s.split("-| |:");
try {
if (a.length >= 3) {
cal = Calendar.getInstance();
cal.set(Calendar.YEAR, Integer.valueOf(a[0]));
cal.set(Calendar.MONTH, Integer.valueOf(a[1]) - 1);
cal.set(Calendar.DATE, Integer.valueOf(a[2]));
}
if (type == 0) {
if (a.length >= 5) {
cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(a[3]));
cal.set(Calendar.MINUTE, Integer.valueOf(a[4]));
if (a.length == 6) {
cal.set(Calendar.SECOND, Integer.valueOf(a[5]));
}
} else {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
}
} else if (type == 1) {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
} else if (type == 2) {
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
}
} catch (Exception e) {
}
if (cal != null) {
return cal.getTime();
}
return null;
}
public static Date stringDateMin(String s) {
Date date = null;
try {
date = shortsdf.parse(s);
} catch (ParseException e) {
}
return date;
}
public static Date stringDate(String s) {
Date date = null;
try {
date = longsdf.parse(s);
} catch (ParseException e) {
}
return date;
}
/**
* 以短格式格式化时间,实例:2010-09-19
* @param time 时间刻度
* @return 格式化后的时间
* @author zhengrunjin @ 2010-09-19
*/
public static String StringDateShortFormat(Long time){
if (time != null) {
return shortsdf.format(new Date(time));
}
return null;
}
public static String StringDate(Long l) {
if (l != null) {
return longsdf.format(new Date(l));
}
return null;
}
/**
* 返回于指定日期间隔一定天数的日期
* @param date
* @param days
* @return
*/
public static Date getSpecDate(Date date, int days) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - days);
return calendar.getTime();
}
public static boolean after(Date date1, Date date2) {
Calendar dc1 = Calendar.getInstance();
dc1.setTime(date1);
Calendar dc2 = Calendar.getInstance();
dc2.setTime(date2);
return dc1.after(dc2);
}
public static boolean before(Date date1, Date date2) {
Calendar dc1 = Calendar.getInstance();
dc1.setTime(date1);
Calendar dc2 = Calendar.getInstance();
dc2.setTime(date2);
return dc1.before(dc2);
}
//日期转换
public static java.sql.Date getBeforeAfterDate(String datestr, int day) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
java.sql.Date olddate = null;
try {
df.setLenient(false);
olddate = new java.sql.Date(df.parse(datestr).getTime());
} catch (ParseException e) {
throw new RuntimeException("日期转换错误");
}
Calendar cal = new GregorianCalendar();
cal.setTime(olddate);
int Year = cal.get(Calendar.YEAR);
int Month = cal.get(Calendar.MONTH);
int Day = cal.get(Calendar.DAY_OF_MONTH);
int NewDay = Day + day;
cal.set(Calendar.YEAR, Year);
cal.set(Calendar.MONTH, Month);
cal.set(Calendar.DAY_OF_MONTH, NewDay);
return new java.sql.Date(cal.getTimeInMillis());
}
//参数日期+小时数得到新日期
//type:1=天数 ,2=小时数 3=月数
public static Date getNewDate(Date d,int num,int type){
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
switch (type) {
case 1:
calendar.add(Calendar.DAY_OF_YEAR, num);
break;
case 2:
calendar.add(Calendar.HOUR_OF_DAY, num);
break;
case 3:
calendar.add(Calendar.MONTH, num);
break;
}
return calendar.getTime();
}
/**
* 两个日期相差的天数,只精确到天
* @param date1
* @param date2
* @return
*/
public static Integer diffDays(Date date1, Date date2){
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(date1);
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(date2);
int days1 = calendar1.get(Calendar.DAY_OF_YEAR);
int days2 = calendar2.get(Calendar.DAY_OF_YEAR);
return Math.abs(days2 - days1);
}
/**
* 返回一天的结束时间
* @param d
* @return
*/
public String getEndTimeOfDays(String d) {
return d.trim() + " 23:59:59";
}
/**
* 去掉日期的时间部分
* @param d
* @return
*/
public String formatDateStr(String d) {
try {
return shortsdf.format(longsdf.parse(d));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static void main(String args[]){
System.out.println(formatDate(getNewDate(new Date(),1 , 3)));
}
/**
* 获取过几分钟的时间
* @param d
* @param num
* @param type
* @return
*/
public static Date getDateAfterSomeMinutes(Date d,int minute){
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
calendar.add(Calendar.MINUTE, minute);
return calendar.getTime();
}
/**
* 获得过几小时的时间
*
* @param d 需要计算的时间类型
* @param hours 小时数
* @return
*/
public static Date addHours(Date d,int hours){
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
calendar.add(Calendar.HOUR, hours);
return calendar.getTime();
}
public static String formatDate(Date date,String format) {
String newDate = "";
if (date == null)
return newDate;
try {
SimpleDateFormat df = new SimpleDateFormat(format);
newDate = df.format(date);
} catch (Exception e) {
e.printStackTrace();
}
return newDate;
}
}
相关推荐
VGA系列之一:VGA显示网络图片
VGA系列之一:VGA显示网络图片VGA系列之一VGA显示网络图片 1 如何用FPGA实现VGA显示 2 网络图片和VGA显示有何区别 3VGA如何显示图片
第一周项目三 时间类(2)增加多秒/分/时
问题及代码 /* *ALL rights reserved. *文件名称: 初学对象 2 *作者:李长鸿 *完成时间:2015.3.22 *问题描述:时间类 */ #include using namespace std; class Time { public: void
数据预处理之数据平滑处理#matlab
介绍基于 MATLAB 的数据平滑方法,主要介绍 smooth 函数、smoothts 函数和 medfilt1 函数的用法。
(八)Java日期工具类DateUtils详解(一)
一、 对指定的日期新增年、月、周、日、小时、分钟、秒、毫秒 public static Date addDays(Date date, int amount) Date date = new Date(); System.out.println(DateUtil.dateToString(date, "yyyy-MM-dd HH:mm:ss"));
UniDexGrasp++算法实战:无需预生成姿态的灵巧抓取测试指南
本文详细解析了UniDexGrasp++算法在灵巧抓取测试中的实战应用,该算法无需预生成姿态即可实现高效抓取,特别适合处理形状不规则的物体。文章涵盖了环境配置、数据集优化、训练流程及实际测试中的调参技巧,帮助开发者快速掌握这一ICCV 2023提出的先进算法。
Linux 音频驱动(六) ALSA音频驱动之PCM Write数据传递过程
目录1. 前言2. PCM Data Flow3. 总结 1. 前言 本文,我们将以回放(Playback,播放音频)为例,讲解PCM Data是如何从用户空间到内核空间,最后传递到Codec。 在Linux 音频驱动(一) ASoC音频框架简介中,我们给出了回放(Playback)PCM数据流示意图: 对于Linux来说,由于分为 user space 和kernel space,而且两者之间不能随便互相访问。因此用户如果播放音频,则需要调用copy_from_user()将用户数据从user spa
Java获取时间
/** * 获取过去passTime天时间 * * @param passTime * @return */ private String getCurrentTime(Integer passTime) { Calendar calendar = Calendar.getInstance(); //时间日期格式化 SimpleDateFormat sdf = new SimpleDateFormat.
赛豆科技 AIVA 汽车智能体架构演进面试题与答案
摘要 赛豆科技AIVA汽车智能体架构从座舱AI演进到整车智能体,最终实现自进化的超级智能体。其核心是"先有AI再有车"的理念,将AI作为产品主轴而非附加功能。架构设计采用端-边-云协同,确保低延迟响应;整车智能体通过Planner、Tool Registry等关键组件实现自主决策;自进化机制结合车端个性化学习和云端群体学习,并设置多重安全验证。多域协作采用分层架构,关键安全功能仍由确定性逻辑控制。该架构实现了从被动响应到主动服务的范式转变,使车辆能够持续进化。
datautil java_java日期处理类DateUtil
packagecom.common.utils;importjava.text.DateFormat;importjava.text.ParseException;importjava.text.SimpleDateFormat;importjava.util.Calendar;importjava.util.Date;public classDateUtil {/*** 功能描述:格式化日期**...
ROS机器人未知环境自主探索功能包explore_lite总结
本系列文章主要针对ROS机器人常使用的未知环境自主探索功能包explore_lite展开全源码的详细解析,并进行概括总结。 本系列文章共包含六篇文章,前五篇文章主要介绍explore_lite功能包中 explore.cpp、costmap_tools.h、frontier_search.cpp、costmap_client.cpp等源码实现文件中全部函数的详细介绍,第六篇文章进行概括总结,包含自主探索功能包explore_lite的简介,实现未知环境自主探索功能的原理及流程总结,效果演示,使用功能包exp
Oracle EBS Interface/API(29) - AP发票API
续上编文章《Oracle EBS Interface/API(28) - 客制化开发AP付款API》背景,介绍如调用官方提供标准AP发票API调用 用户界面 Invoices(Payables Manager->Invoices->Entry->Invoices) Open Interface Invoices(Payables Manager->Invoices->Entry->Open Interface Invoices) 快速参考 参考点 内容.
Gazebo中sdf文件和urdf和xacro文件的区别
sdf文件、urdf文件和xacro文件都是模型文件。 xacro文件是urdf文件的改进版,urdf文件只能在rviz等中显示,不能在仿真器中显示出来。 xacro文件可以在gazebo仿真器中显示出来,相对urdf文件,xacro文件增加了更多的属性设置标签。 sdf文件和urdf文件、xacro文件都可以加载dae等三维模型文件。 sdf和urdf、xacro的区别是: ...
vue2/3 - 详细实现高德地图轨迹回放,vue高德地图车辆历史行驶轨迹播放,在地图上绘制行程轨迹|起点和终端的路程绘制|用户运动轨迹绘制及播放等(支持开始/暂停、进度条拖放、控制播放轨迹的倍速等)
vue2,vue3,nuxt,高德地图,轨迹,vue高德地图轨迹回放,历史轨迹回放,轨迹回放功能支持倍速及进度条拖拽,VUE高德地图轨迹回放、倍速调整、进度条拖拽,vue3高德地图轨迹回放,Vue实现地图路径回放,vue中使用高德地图实现历史轨迹回放并能控制播放轨迹的倍速,多条轨迹陆续播放,巡航轨迹做带进度条和倍速的轨迹回放,Vue高德地图路径回放,历史轨迹回放并能控制播放轨迹的倍速,使用高德地图实现轨迹播放和进度条控制,vue高德地图如何实现轨迹回放,高德地图做轨迹绘制用什么api,高德轨迹API,驾车轨
DateUtil工具类封装
类说明:日期工具类* * 详细描述:
visio安装包
Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
java日期工具类DateUtil
一名优秀的程序员,不仅需要有着丰富解决问题的方案,还需要的便是代码的沉淀,这不仅有助于自己快速的开发程序,也有利于保证程序的健壮。那如何才能沉淀自己的”代码“呢?从自己编写util开始其实就是一个不错的选择。 虽然网络上也有类似的工具类,但我愿意自己写的原因有三: 1、好代码并不容易找,不满足需要的倒是不少 2、可能存在未知的bug 3、丧失了巩固和提高自己的机会 废话不多说,我的源码如
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
dateutil 日期计算_时间工具类DateUtil的使用
###前言在Android开发过程中,我们经常会用到时间相关方法。这里我封装一个时间工具类`DateUtil`,以方便使用。今天涉及内容:1. DateUtil在MainActivity中的使用2. 效果图和项目结构图先来波效果图####一.DateUtil在MainActivity...
IEM模型,地表粗糙度模拟
利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟
DateUtil 时间工具类
时间工具类 /** * 操作时间工具类s */ public class DateUtil extends DateUtils { //判断两个日期时间是否相距一天之内,一天之内返回true,否则反手false public static boolean judgmentDate(String date1, String date2) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d HH:
Java # DateUtil时间工具类
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * 时间工具类 * * @author * @create 2019-07-26 9:27 */ public class DateUtil { /** * long类型转换为String类型 * * @param * @param formatType 要转.
hutool的 DateUtil工具类相关方法
hutool
工具类----DateUtil
DateUtil工具类 public static String getDateValue(Map<String, Object> dataMap, String name) throws ParseException{ Object obj = dataMap.get(name); if (obj == null) return ""; String str = obj.t...
Hutool Java工具类库-DateUtil(时间工具类)
java日期工具类(持续更新)
Java学习Hutool工具库中的DateUtil工具类
Java学习Hutool工具库中的DateUtil工具类
harmony-utils之DateUtil,日期工具类
摘要: harmony-utils是鸿蒙系统的一款多功能工具库,其中DateUtil提供了丰富的日期处理方法,包括日期格式化、日期比较、日期计算等功能。支持时间戳、字符串、Date对象等多种日期类型输入,可实现获取当前日期、判断闰年、计算日期差、获取前后日期等常见操作。如getFormatDate进行日期格式化,compareDays计算日期差值,getBeforeDay获取前一天日期等。该工具类简化了鸿蒙应用开发中的日期处理,支持20多种日期格式,满足各类业务场景需求。需在UIAbility中初始化后使用
JAVA 实用时间工具类-DateUtil
获取两个日期之间的所有日期集合 List<Date> betweenDays(Date startDate, Date endDate)* 获取指定日期前/后n小时的日期 Date getDifferHour(Date date, int hours)* 获取指定日期前/后年的日期 Date getDifferYear(Date date, int years)* 获取指定日期前/后n天的日期 Date getDifferDay(Date date, int days)
【Java】Java中的日期转化格式DateUtil工具类-(87个方法)
【代码】Java中的日期转化格式DateUtil工具类-(87个方法)
1万+



被折叠的 条评论
为什么被折叠?



