Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
杨图强
ewaytek-deepseek
Commits
0487b6d5
Commit
0487b6d5
authored
Aug 28, 2025
by
何处是我家
Browse files
提交
parents
Changes
148
Hide whitespace changes
Inline
Side-by-side
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/DemoModeException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception
;
/**
* 演示模式异常
*
* @author admin
*/
public
class
DemoModeException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
public
DemoModeException
()
{
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/GlobalException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception
;
/**
* 全局异常
*
* @author admin
*/
public
class
GlobalException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 错误提示
*/
private
String
message
;
/**
* 错误明细,内部调试错误
* <p>
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
*/
private
String
detailMessage
;
/**
* 空构造方法,避免反序列化问题
*/
public
GlobalException
()
{
}
public
GlobalException
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getDetailMessage
()
{
return
detailMessage
;
}
public
GlobalException
setDetailMessage
(
String
detailMessage
)
{
this
.
detailMessage
=
detailMessage
;
return
this
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
GlobalException
setMessage
(
String
message
)
{
this
.
message
=
message
;
return
this
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/ServiceException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception
;
/**
* 业务异常
*
* @author admin
*/
public
final
class
ServiceException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 错误码
*/
private
Integer
code
;
/**
* 错误提示
*/
private
String
message
;
/**
* 错误明细,内部调试错误
* <p>
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
*/
private
String
detailMessage
;
/**
* 空构造方法,避免反序列化问题
*/
public
ServiceException
()
{
}
public
ServiceException
(
String
message
)
{
this
.
message
=
message
;
}
public
ServiceException
(
String
message
,
Integer
code
)
{
this
.
message
=
message
;
this
.
code
=
code
;
}
public
String
getDetailMessage
()
{
return
detailMessage
;
}
public
ServiceException
setDetailMessage
(
String
detailMessage
)
{
this
.
detailMessage
=
detailMessage
;
return
this
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
ServiceException
setMessage
(
String
message
)
{
this
.
message
=
message
;
return
this
;
}
public
Integer
getCode
()
{
return
code
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/UtilException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception
;
/**
* 工具类异常
*
* @author admin
*/
public
class
UtilException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
8247610319171014183L
;
public
UtilException
(
Throwable
e
)
{
super
(
e
.
getMessage
(),
e
);
}
public
UtilException
(
String
message
)
{
super
(
message
);
}
public
UtilException
(
String
message
,
Throwable
throwable
)
{
super
(
message
,
throwable
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/base/BaseException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.base
;
import
com.ewaytek.deepseek.common.utils.MessageUtils
;
import
com.ewaytek.deepseek.common.utils.StringUtils
;
/**
* 基础异常
*
* @author admin
*/
public
class
BaseException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 所属模块
*/
private
final
String
module
;
/**
* 错误码
*/
private
final
String
code
;
/**
* 错误码对应的参数
*/
private
final
Object
[]
args
;
/**
* 错误消息
*/
private
final
String
defaultMessage
;
public
BaseException
(
String
module
,
String
code
,
Object
[]
args
,
String
defaultMessage
)
{
this
.
module
=
module
;
this
.
code
=
code
;
this
.
args
=
args
;
this
.
defaultMessage
=
defaultMessage
;
}
public
BaseException
(
String
module
,
String
code
,
Object
[]
args
)
{
this
(
module
,
code
,
args
,
null
);
}
public
BaseException
(
String
module
,
String
defaultMessage
)
{
this
(
module
,
null
,
null
,
defaultMessage
);
}
public
BaseException
(
String
code
,
Object
[]
args
)
{
this
(
null
,
code
,
args
,
null
);
}
public
BaseException
(
String
defaultMessage
)
{
this
(
null
,
null
,
null
,
defaultMessage
);
}
@Override
public
String
getMessage
()
{
String
message
=
null
;
if
(!
StringUtils
.
isEmpty
(
code
))
{
message
=
MessageUtils
.
message
(
code
,
args
);
}
if
(
message
==
null
)
{
message
=
defaultMessage
;
}
return
message
;
}
public
String
getModule
()
{
return
module
;
}
public
String
getCode
()
{
return
code
;
}
public
Object
[]
getArgs
()
{
return
args
;
}
public
String
getDefaultMessage
()
{
return
defaultMessage
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/file/FileException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.file
;
import
com.ewaytek.deepseek.common.exception.base.BaseException
;
/**
* 文件信息异常类
*
* @author admin
*/
public
class
FileException
extends
BaseException
{
private
static
final
long
serialVersionUID
=
1L
;
public
FileException
(
String
code
,
Object
[]
args
)
{
super
(
"file"
,
code
,
args
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/file/FileNameLengthLimitExceededException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.file
;
/**
* 文件名称超长限制异常类
*
* @author admin
*/
public
class
FileNameLengthLimitExceededException
extends
FileException
{
private
static
final
long
serialVersionUID
=
1L
;
public
FileNameLengthLimitExceededException
(
int
defaultFileNameLength
)
{
super
(
"upload.filename.exceed.length"
,
new
Object
[]{
defaultFileNameLength
});
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/file/FileSizeLimitExceededException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.file
;
/**
* 文件名大小限制异常类
*
* @author admin
*/
public
class
FileSizeLimitExceededException
extends
FileException
{
private
static
final
long
serialVersionUID
=
1L
;
public
FileSizeLimitExceededException
(
long
defaultMaxSize
)
{
super
(
"upload.exceed.maxSize"
,
new
Object
[]{
defaultMaxSize
});
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/file/FileUploadException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.file
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
/**
* 文件上传异常类
*
* @author admin
*/
public
class
FileUploadException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
Throwable
cause
;
public
FileUploadException
()
{
this
(
null
,
null
);
}
public
FileUploadException
(
final
String
msg
)
{
this
(
msg
,
null
);
}
public
FileUploadException
(
String
msg
,
Throwable
cause
)
{
super
(
msg
);
this
.
cause
=
cause
;
}
@Override
public
void
printStackTrace
(
PrintStream
stream
)
{
super
.
printStackTrace
(
stream
);
if
(
cause
!=
null
)
{
stream
.
println
(
"Caused by:"
);
cause
.
printStackTrace
(
stream
);
}
}
@Override
public
void
printStackTrace
(
PrintWriter
writer
)
{
super
.
printStackTrace
(
writer
);
if
(
cause
!=
null
)
{
writer
.
println
(
"Caused by:"
);
cause
.
printStackTrace
(
writer
);
}
}
@Override
public
Throwable
getCause
()
{
return
cause
;
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/file/InvalidExtensionException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.file
;
import
java.util.Arrays
;
/**
* 文件上传 误异常类
*
* @author admin
*/
public
class
InvalidExtensionException
extends
FileUploadException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
[]
allowedExtension
;
private
final
String
extension
;
private
final
String
filename
;
public
InvalidExtensionException
(
String
[]
allowedExtension
,
String
extension
,
String
filename
)
{
super
(
"文件["
+
filename
+
"]后缀["
+
extension
+
"]不正确,请上传"
+
Arrays
.
toString
(
allowedExtension
)
+
"格式"
);
this
.
allowedExtension
=
allowedExtension
;
this
.
extension
=
extension
;
this
.
filename
=
filename
;
}
public
String
[]
getAllowedExtension
()
{
return
allowedExtension
;
}
public
String
getExtension
()
{
return
extension
;
}
public
String
getFilename
()
{
return
filename
;
}
public
static
class
InvalidImageExtensionException
extends
InvalidExtensionException
{
private
static
final
long
serialVersionUID
=
1L
;
public
InvalidImageExtensionException
(
String
[]
allowedExtension
,
String
extension
,
String
filename
)
{
super
(
allowedExtension
,
extension
,
filename
);
}
}
public
static
class
InvalidFlashExtensionException
extends
InvalidExtensionException
{
private
static
final
long
serialVersionUID
=
1L
;
public
InvalidFlashExtensionException
(
String
[]
allowedExtension
,
String
extension
,
String
filename
)
{
super
(
allowedExtension
,
extension
,
filename
);
}
}
public
static
class
InvalidMediaExtensionException
extends
InvalidExtensionException
{
private
static
final
long
serialVersionUID
=
1L
;
public
InvalidMediaExtensionException
(
String
[]
allowedExtension
,
String
extension
,
String
filename
)
{
super
(
allowedExtension
,
extension
,
filename
);
}
}
public
static
class
InvalidVideoExtensionException
extends
InvalidExtensionException
{
private
static
final
long
serialVersionUID
=
1L
;
public
InvalidVideoExtensionException
(
String
[]
allowedExtension
,
String
extension
,
String
filename
)
{
super
(
allowedExtension
,
extension
,
filename
);
}
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/job/TaskException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.job
;
/**
* 计划策略异常
*
* @author admin
*/
public
class
TaskException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
Code
code
;
public
TaskException
(
String
msg
,
Code
code
)
{
this
(
msg
,
code
,
null
);
}
public
TaskException
(
String
msg
,
Code
code
,
Exception
nestedEx
)
{
super
(
msg
,
nestedEx
);
this
.
code
=
code
;
}
public
Code
getCode
()
{
return
code
;
}
public
enum
Code
{
TASK_EXISTS
,
NO_TASK_EXISTS
,
TASK_ALREADY_STARTED
,
UNKNOWN
,
CONFIG_ERROR
,
TASK_NODE_NOT_AVAILABLE
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/BlackListException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
/**
* 黑名单IP异常类
*
* @author admin
*/
public
class
BlackListException
extends
UserException
{
private
static
final
long
serialVersionUID
=
1L
;
public
BlackListException
()
{
super
(
"login.blocked"
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/CaptchaException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
/**
* 验证码错误异常类
*
* @author admin
*/
public
class
CaptchaException
extends
UserException
{
private
static
final
long
serialVersionUID
=
1L
;
public
CaptchaException
()
{
super
(
"user.jcaptcha.error"
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/CaptchaExpireException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
/**
* 验证码失效异常类
*
* @author admin
*/
public
class
CaptchaExpireException
extends
UserException
{
private
static
final
long
serialVersionUID
=
1L
;
public
CaptchaExpireException
()
{
super
(
"user.jcaptcha.expire"
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/UserException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
import
com.ewaytek.deepseek.common.exception.base.BaseException
;
/**
* 用户信息异常类
*
* @author admin
*/
public
class
UserException
extends
BaseException
{
private
static
final
long
serialVersionUID
=
1L
;
public
UserException
(
String
code
,
Object
[]
args
)
{
super
(
"user"
,
code
,
args
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/UserNotExistsException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
/**
* 用户不存在异常类
*
* @author admin
*/
public
class
UserNotExistsException
extends
UserException
{
private
static
final
long
serialVersionUID
=
1L
;
public
UserNotExistsException
()
{
super
(
"user.not.exists"
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/UserPasswordNotMatchException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
/**
* 用户密码不正确或不符合规范异常类
*
* @author admin
*/
public
class
UserPasswordNotMatchException
extends
UserException
{
private
static
final
long
serialVersionUID
=
1L
;
public
UserPasswordNotMatchException
()
{
super
(
"user.password.not.match"
,
null
);
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/exception/user/UserPasswordRetryLimitExceedException.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.exception.user
;
/**
* 用户错误最大次数异常类
*
* @author admin
*/
public
class
UserPasswordRetryLimitExceedException
extends
UserException
{
private
static
final
long
serialVersionUID
=
1L
;
public
UserPasswordRetryLimitExceedException
(
int
retryLimitCount
,
int
lockTime
)
{
super
(
"user.password.retry.limit.exceed"
,
new
Object
[]{
retryLimitCount
,
lockTime
});
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/utils/Arith.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.utils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
/**
* 精确的浮点数运算
*
* @author admin
*/
public
class
Arith
{
/**
* 默认除法运算精度
*/
private
static
final
int
DEF_DIV_SCALE
=
10
;
/**
* 这个类不能实例化
*/
private
Arith
()
{
}
/**
* 提供精确的加法运算。
*
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public
static
double
add
(
double
v1
,
double
v2
)
{
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
add
(
b2
).
doubleValue
();
}
/**
* 提供精确的减法运算。
*
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public
static
double
sub
(
double
v1
,
double
v2
)
{
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
subtract
(
b2
).
doubleValue
();
}
/**
* 提供精确的乘法运算。
*
* @param v1 被乘数
* @param v2 乘数
* @return 两个参数的积
*/
public
static
double
mul
(
double
v1
,
double
v2
)
{
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
multiply
(
b2
).
doubleValue
();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
* 小数点以后10位,以后的数字四舍五入。
*
* @param v1 被除数
* @param v2 除数
* @return 两个参数的商
*/
public
static
double
div
(
double
v1
,
double
v2
)
{
return
div
(
v1
,
v2
,
DEF_DIV_SCALE
);
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
* 定精度,以后的数字四舍五入。
*
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public
static
double
div
(
double
v1
,
double
v2
,
int
scale
)
{
if
(
scale
<
0
)
{
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
if
(
b1
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
BigDecimal
.
ZERO
.
doubleValue
();
}
return
b1
.
divide
(
b2
,
scale
,
RoundingMode
.
HALF_UP
).
doubleValue
();
}
/**
* 提供精确的小数位四舍五入处理。
*
* @param v 需要四舍五入的数字
* @param scale 小数点后保留几位
* @return 四舍五入后的结果
*/
public
static
double
round
(
double
v
,
int
scale
)
{
if
(
scale
<
0
)
{
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
BigDecimal
b
=
new
BigDecimal
(
Double
.
toString
(
v
));
BigDecimal
one
=
new
BigDecimal
(
"1"
);
return
b
.
divide
(
one
,
scale
,
RoundingMode
.
HALF_UP
).
doubleValue
();
}
}
ewaytek-deepseek-common/src/main/java/com/ewaytek/deepseek/common/utils/DateUtils.java
0 → 100644
View file @
0487b6d5
package
com.ewaytek.deepseek.common.utils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
java.lang.management.ManagementFactory
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.*
;
import
java.util.Date
;
/**
* 时间工具类
*
* @author admin
*/
public
class
DateUtils
extends
org
.
apache
.
commons
.
lang3
.
time
.
DateUtils
{
public
static
String
YYYY
=
"yyyy"
;
public
static
String
YYYY_MM
=
"yyyy-MM"
;
public
static
String
YYYY_MM_DD
=
"yyyy-MM-dd"
;
public
static
String
YYYYMMDDHHMMSS
=
"yyyyMMddHHmmss"
;
public
static
String
YYYY_MM_DD_HH_MM_SS
=
"yyyy-MM-dd HH:mm:ss"
;
private
static
final
String
[]
parsePatterns
=
{
"yyyy-MM-dd"
,
"yyyy-MM-dd HH:mm:ss"
,
"yyyy-MM-dd HH:mm"
,
"yyyy-MM"
,
"yyyy/MM/dd"
,
"yyyy/MM/dd HH:mm:ss"
,
"yyyy/MM/dd HH:mm"
,
"yyyy/MM"
,
"yyyy.MM.dd"
,
"yyyy.MM.dd HH:mm:ss"
,
"yyyy.MM.dd HH:mm"
,
"yyyy.MM"
};
/**
* 获取当前Date型日期
*
* @return Date() 当前日期
*/
public
static
Date
getNowDate
()
{
return
new
Date
();
}
/**
* 获取当前日期, 默认格式为yyyy-MM-dd
*
* @return String
*/
public
static
String
getDate
()
{
return
dateTimeNow
(
YYYY_MM_DD
);
}
public
static
final
String
getTime
()
{
return
dateTimeNow
(
YYYY_MM_DD_HH_MM_SS
);
}
public
static
final
String
dateTimeNow
()
{
return
dateTimeNow
(
YYYYMMDDHHMMSS
);
}
public
static
final
String
dateTimeNow
(
final
String
format
)
{
return
parseDateToStr
(
format
,
new
Date
());
}
public
static
final
String
dateTime
(
final
Date
date
)
{
return
parseDateToStr
(
YYYY_MM_DD
,
date
);
}
public
static
final
String
parseDateToStr
(
final
String
format
,
final
Date
date
)
{
return
new
SimpleDateFormat
(
format
).
format
(
date
);
}
public
static
final
Date
dateTime
(
final
String
format
,
final
String
ts
)
{
try
{
return
new
SimpleDateFormat
(
format
).
parse
(
ts
);
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
* 日期路径 即年/月/日 如2018/08/08
*/
public
static
final
String
datePath
()
{
Date
now
=
new
Date
();
return
DateFormatUtils
.
format
(
now
,
"yyyy/MM/dd"
);
}
/**
* 日期路径 即年/月/日 如20180808
*/
public
static
final
String
dateTime
()
{
Date
now
=
new
Date
();
return
DateFormatUtils
.
format
(
now
,
"yyyyMMdd"
);
}
/**
* 日期型字符串转化为日期 格式
*/
public
static
Date
parseDate
(
Object
str
)
{
if
(
str
==
null
)
{
return
null
;
}
try
{
return
parseDate
(
str
.
toString
(),
parsePatterns
);
}
catch
(
ParseException
e
)
{
return
null
;
}
}
/**
* 获取服务器启动时间
*/
public
static
Date
getServerStartDate
()
{
long
time
=
ManagementFactory
.
getRuntimeMXBean
().
getStartTime
();
return
new
Date
(
time
);
}
/**
* 计算相差天数
*/
public
static
int
differentDaysByMillisecond
(
Date
date1
,
Date
date2
)
{
return
Math
.
abs
((
int
)
((
date2
.
getTime
()
-
date1
.
getTime
())
/
(
1000
*
3600
*
24
)));
}
/**
* 计算时间差
*
* @param endDate 最后时间
* @param startTime 开始时间
* @return 时间差(天/小时/分钟)
*/
public
static
String
timeDistance
(
Date
endDate
,
Date
startTime
)
{
long
nd
=
1000
*
24
*
60
*
60
;
long
nh
=
1000
*
60
*
60
;
long
nm
=
1000
*
60
;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long
diff
=
endDate
.
getTime
()
-
startTime
.
getTime
();
// 计算差多少天
long
day
=
diff
/
nd
;
// 计算差多少小时
long
hour
=
diff
%
nd
/
nh
;
// 计算差多少分钟
long
min
=
diff
%
nd
%
nh
/
nm
;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return
day
+
"天"
+
hour
+
"小时"
+
min
+
"分钟"
;
}
/**
* 增加 LocalDateTime ==> Date
*/
public
static
Date
toDate
(
LocalDateTime
temporalAccessor
)
{
ZonedDateTime
zdt
=
temporalAccessor
.
atZone
(
ZoneId
.
systemDefault
());
return
Date
.
from
(
zdt
.
toInstant
());
}
/**
* 增加 LocalDate ==> Date
*/
public
static
Date
toDate
(
LocalDate
temporalAccessor
)
{
LocalDateTime
localDateTime
=
LocalDateTime
.
of
(
temporalAccessor
,
LocalTime
.
of
(
0
,
0
,
0
));
ZonedDateTime
zdt
=
localDateTime
.
atZone
(
ZoneId
.
systemDefault
());
return
Date
.
from
(
zdt
.
toInstant
());
}
}
Prev
1
2
3
4
5
6
…
8
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment