包装类型支持转为时间类型

This commit is contained in:
2023-09-04 20:35:42 +08:00
parent 2886126ae7
commit faafa8ee2a
3 changed files with 41 additions and 0 deletions

View File

@ -950,6 +950,22 @@ func (str String) ToNumberSlice(splitChar ...string) Float64SliceResult {
return str.ToFloat64Slice(splitChar...)
}
// ToDuration 转换为时间格式
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 20:31 2023/9/4
func (str String) ToDuration(timeUnit time.Duration) DurationResult {
int64Val := str.ToInt64()
if nil != int64Val.Err {
return DurationResult{
Value: 0,
Err: int64Val.Err,
}
}
return Int(int64Val.Value).ToDuration(timeUnit)
}
// ToStringSlice ...
//
// Author : go_developer@163.com<白茶清欢>