mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-14 11:37:31 +08:00
Full-stack AI assistant built on Spring AI Alibaba. Features: ReAct Agent, Plan-and-Execute, MCP Protocol, Multi-Model, Multi-Channel. Apache-2.0 License
36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
package vip.mate.tool.builtin;
|
|
|
|
import org.springframework.ai.tool.annotation.Tool;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
/**
|
|
* 内置工具:日期时间
|
|
*
|
|
* @author MateClaw Team
|
|
*/
|
|
@Component
|
|
public class DateTimeTool {
|
|
|
|
@Tool(description = "获取当前日期和时间,返回格式为 yyyy-MM-dd HH:mm:ss")
|
|
public String getCurrentDateTime() {
|
|
return LocalDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
}
|
|
|
|
@Tool(description = "获取当前日期,返回格式为 yyyy-MM-dd")
|
|
public String getCurrentDate() {
|
|
return LocalDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
}
|
|
|
|
@Tool(description = "获取当前时间,返回格式为 HH:mm:ss")
|
|
public String getCurrentTime() {
|
|
return LocalDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
|
|
}
|
|
}
|