mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 03:55:09 +08:00
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 = "Get current date and time in yyyy-MM-dd HH:mm:ss format")
|
|
public String getCurrentDateTime() {
|
|
return LocalDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
}
|
|
|
|
@Tool(description = "Get current date in yyyy-MM-dd format")
|
|
public String getCurrentDate() {
|
|
return LocalDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
}
|
|
|
|
@Tool(description = "Get current time in HH:mm:ss format")
|
|
public String getCurrentTime() {
|
|
return LocalDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
|
|
}
|
|
}
|