Class DateFunctions

java.lang.Object
cloud.opencode.base.expression.function.DateFunctions

public final class DateFunctions extends Object
Date Functions 日期函数

Provides built-in date and time functions for expressions.

为表达式提供内置的日期时间函数。

Features | 主要功能:

  • Current: now, today, currenttime, timestamp - 当前时间
  • Creation: date, datetime, time - 创建
  • Extraction: year, month, day, hour, minute, second, dayofweek, dayofyear - 提取
  • Arithmetic: adddays, addmonths, addyears, addhours, addminutes, addseconds - 算术
  • Difference: daysbetween, monthsbetween, yearsbetween, hoursbetween - 差值
  • Formatting: formatdate, parsedate, parsedatetime - 格式化
  • Boundaries: startofday, endofday, startofmonth, endofmonth - 边界
  • Checks: isbefore, isafter, isweekend, isleapyear - 检查

Usage Examples | 使用示例:

Object today = OpenExpression.eval("today()");
Object year = OpenExpression.eval("year(today())");
Object fmt = OpenExpression.eval("formatdate(today(), 'yyyy-MM-dd')");

Security | 安全性:

  • Thread-safe: Yes, stateless utility class - 线程安全: 是,无状态工具类
  • Null-safe: Yes, null arguments return current date/time or defaults - 空值安全: 是,null参数返回当前日期/时间或默认值
Since:
JDK 25, opencode-base-expression V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • getFunctions

      public static Map<String,Function> getFunctions()
      Get all date functions 获取所有日期函数
      Returns:
      the function map | 函数映射