generated from mingliqiye/lib-tem
Compare commits
3 Commits
c54cab4a44
...
93f8cd9386
Author | SHA1 | Date | |
---|---|---|---|
93f8cd9386 | |||
ab97ba57c8 | |||
57efd3c8c4 |
8
.github/workflows/build.yaml
vendored
8
.github/workflows/build.yaml
vendored
@ -9,7 +9,13 @@ jobs:
|
|||||||
runs-on: ubuntu-dev
|
runs-on: ubuntu-dev
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
|
167
README.md
Normal file
167
README.md
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
# mingli-utils
|
||||||
|
|
||||||
|
一个功能丰富的Java工具类库,提供字符串处理、时间处理、文件操作、网络工具、哈希计算等常用工具方法。
|
||||||
|
|
||||||
|
## 项目概述
|
||||||
|
|
||||||
|
mingli-utils 是一个 Java 工具类库,提供各种常用的工具方法,旨在简化开发流程,减少重复代码。
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
- JDK 版本: Java 8
|
||||||
|
- 构建工具: Gradle (Kotlin DSL)
|
||||||
|
- 依赖库:
|
||||||
|
- Lombok 1.18.38: 用于简化 Java Bean 代码
|
||||||
|
- Jackson Databind 2.19.2: 用于 JSON 序列化
|
||||||
|
- MyBatis 3.5.19: 持久层框架
|
||||||
|
- Spring Boot Starter 2.7.14: Spring Boot基础依赖
|
||||||
|
- Bouncy Castle 1.81: 加密算法库
|
||||||
|
- UUID Creator 6.1.0: UUID生成工具
|
||||||
|
- jBCrypt 0.4: BCrypt加密实现
|
||||||
|
- JetBrains Annotations 24.0.0: 注解库
|
||||||
|
|
||||||
|
## 主要功能模块
|
||||||
|
|
||||||
|
### 字符串处理 (StringUtil)
|
||||||
|
|
||||||
|
提供常用的字符串操作方法:
|
||||||
|
|
||||||
|
- `toString()`: 对象转字符串
|
||||||
|
- `format()`: 格式化字符串
|
||||||
|
- `isEmpty()`: 判断字符串是否为空
|
||||||
|
- `join()`: 连接字符串
|
||||||
|
- `split()`: 分割字符串
|
||||||
|
|
||||||
|
### 集合工具 (Lists)
|
||||||
|
|
||||||
|
提供创建各种List实现的便捷方法:
|
||||||
|
|
||||||
|
- `newArrayList()`: 创建ArrayList实例
|
||||||
|
- `newLinkedList()`: 创建LinkedList实例
|
||||||
|
- `newVector()`: 创建Vector实例
|
||||||
|
|
||||||
|
### 时间处理 (time)
|
||||||
|
|
||||||
|
提供时间相关功能:
|
||||||
|
|
||||||
|
- `DateTime`: 时间处理类,封装了LocalDateTime的操作
|
||||||
|
- `DateTimeOffset`: 时间偏移量处理
|
||||||
|
- `Formatter`: 常用时间格式枚举
|
||||||
|
- `DateTimeUnit`: 时间单位常量定义
|
||||||
|
|
||||||
|
### 文件操作 (FileUtil)
|
||||||
|
|
||||||
|
提供文件读写等操作:
|
||||||
|
|
||||||
|
- `readFileToString()`: 读取文件内容为字符串
|
||||||
|
- `writeStringToFile()`: 将字符串写入文件
|
||||||
|
- `readLines()`: 读取文件内容为字符串列表(按行分割)
|
||||||
|
- `writeLines()`: 将字符串列表写入文件(每行一个元素)
|
||||||
|
- `copyFile()`: 复制文件
|
||||||
|
- `deleteFile()`: 删除文件
|
||||||
|
- `exists()`: 检查文件是否存在
|
||||||
|
- `getFileSize()`: 获取文件大小
|
||||||
|
|
||||||
|
### 网络工具 (network)
|
||||||
|
|
||||||
|
提供网络地址处理功能:
|
||||||
|
|
||||||
|
- `NetworkEndpoint`: 网络端点(IP+端口)封装
|
||||||
|
- `NetworkAddress`: 网络地址处理(支持IPv4/IPv6)
|
||||||
|
- `NetworkPort`: 网络端口处理
|
||||||
|
|
||||||
|
### 哈希工具 (HashUtils)
|
||||||
|
|
||||||
|
提供哈希计算功能:
|
||||||
|
|
||||||
|
- `calculateFileHash()`: 计算文件哈希值
|
||||||
|
- `bcrypt()`: BCrypt加密
|
||||||
|
- `checkBcrypt()`: 验证BCrypt哈希
|
||||||
|
|
||||||
|
### 系统工具 (SystemUtil)
|
||||||
|
|
||||||
|
提供系统相关工具方法:
|
||||||
|
|
||||||
|
- `isWindows()/isMac()/isUnix()`: 操作系统类型判断
|
||||||
|
- `getJdkVersion()`: 获取JDK版本
|
||||||
|
- `getLocalIps()`: 获取本地IP地址
|
||||||
|
|
||||||
|
### UUID工具 (uuid)
|
||||||
|
|
||||||
|
提供UUID处理功能:
|
||||||
|
|
||||||
|
- `UUID`: UUID封装类,支持时间戳型UUID
|
||||||
|
|
||||||
|
### 并发工具 (concurrent)
|
||||||
|
|
||||||
|
提供线程安全的数据结构:
|
||||||
|
|
||||||
|
- `IsChanged`: 基于CAS操作的线程安全包装类
|
||||||
|
|
||||||
|
### 函数式工具 (functions)
|
||||||
|
|
||||||
|
提供函数式编程支持:
|
||||||
|
|
||||||
|
- `Debouncer`: 防抖器实现
|
||||||
|
|
||||||
|
## 使用示例
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 字符串格式化
|
||||||
|
String message =
|
||||||
|
StringUtil.format("Hello {}, you are {} years old", "张三", 25);
|
||||||
|
|
||||||
|
// 创建列表
|
||||||
|
List<String> fruits = Lists.newArrayList("苹果", "香蕉", "橙子");
|
||||||
|
|
||||||
|
// 连接字符串
|
||||||
|
String result = StringUtil.join(", ", fruits);
|
||||||
|
|
||||||
|
// 时间处理
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
String formatted = now.format(Formatter.STANDARD_DATETIME);
|
||||||
|
|
||||||
|
// 文件操作
|
||||||
|
FileUtil.
|
||||||
|
|
||||||
|
writeStringToFile("example.txt","Hello World");
|
||||||
|
|
||||||
|
String content = FileUtil.readFileToString("example.txt");
|
||||||
|
|
||||||
|
// 网络地址处理
|
||||||
|
NetworkEndpoint endpoint = NetworkEndpoint.of("127.0.0.1", 8080);
|
||||||
|
InetSocketAddress address = endpoint.toInetSocketAddress();
|
||||||
|
|
||||||
|
// 哈希计算
|
||||||
|
String hash = HashUtils.bcrypt("password");
|
||||||
|
boolean matches = HashUtils.checkBcrypt("password", hash);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 构建和运行
|
||||||
|
|
||||||
|
使用以下命令构建项目:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew build
|
||||||
|
```
|
||||||
|
|
||||||
|
发布到本地Maven仓库:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./gradlew publishToMavenLocal
|
||||||
|
```
|
||||||
|
|
||||||
|
## 项目配置
|
||||||
|
|
||||||
|
项目在 `gradle.properties` 中定义了以下配置:
|
||||||
|
|
||||||
|
```properties
|
||||||
|
JDKVERSIONS=1.8
|
||||||
|
GROUPSID=com.mingliqiye.utils
|
||||||
|
ARTIFACTID=mingli-utils
|
||||||
|
VERSIONS=1.0.4
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
本项目采用Apache 2.0许可证,详细信息请查看 [LICENSE](LICENSE) 文件。
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,7 @@
|
|||||||
#Thu Jun 26 08:26:37 CST 2025
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://repository.mingliqiye.com/repository/raw/gradle/gradle-8.14.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-1-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
49
gradlew
vendored
49
gradlew
vendored
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -15,6 +15,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@ -55,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@ -80,13 +82,11 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@ -114,7 +114,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@ -133,22 +133,29 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
41
gradlew.bat
vendored
41
gradlew.bat
vendored
@ -13,8 +13,10 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@ -25,7 +27,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@ -1,6 +1,39 @@
|
|||||||
package com.mingliqiye.utils;
|
package com.mingliqiye.utils;
|
||||||
|
|
||||||
|
import com.mingliqiye.utils.collection.Lists;
|
||||||
|
import com.mingliqiye.utils.string.StringUtil;
|
||||||
|
import com.mingliqiye.utils.time.DateTime;
|
||||||
|
import com.mingliqiye.utils.time.Formatter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {}
|
public static void main(String[] args) {
|
||||||
}
|
// 字符串工具使用示例
|
||||||
|
System.out.println("=== 字符串工具使用示例 ===");
|
||||||
|
String formatted = StringUtil.format("你好 {},今天是{}年{}月{}日", "张三", 2025, 7, 25);
|
||||||
|
System.out.println(formatted);
|
||||||
|
|
||||||
|
List<String> fruits = Lists.newArrayList("苹果", "香蕉", "橙子");
|
||||||
|
String joined = StringUtil.join(", ", fruits);
|
||||||
|
System.out.println("水果列表: " + joined);
|
||||||
|
|
||||||
|
// 时间工具使用示例
|
||||||
|
System.out.println("\n=== 时间工具使用示例 ===");
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
System.out.println("当前时间: " + now);
|
||||||
|
System.out.println("标准格式: " + now.format(Formatter.STANDARD_DATETIME));
|
||||||
|
|
||||||
|
DateTime specificDate = DateTime.of(2025, 1, 1, 12, 0, 0);
|
||||||
|
System.out.println("指定时间: " + specificDate.format(Formatter.STANDARD_DATETIME));
|
||||||
|
|
||||||
|
// 集合工具使用示例
|
||||||
|
System.out.println("\n=== 集合工具使用示例 ===");
|
||||||
|
List<Integer> numbers = Lists.newArrayList(10, 20, 30);
|
||||||
|
System.out.println("数字列表: " + numbers);
|
||||||
|
|
||||||
|
List<String> linkedList = Lists.newLinkedList("第一个", "第二个", "第三个");
|
||||||
|
System.out.println("链表内容: " + linkedList);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user