import moment.Moment; import moment.format.FormatOptions; public class MomentExample { public static void main(String[] args) { Moment today = Moment.now(); Moment tomorrow = today.add(1, Moment.Unit.DAYS); Moment yesterday = tomorrow.subtract(2, Moment.Unit.DAYS); String formattedDate = today.format("yyyy-MM-dd", FormatOptions.defaults()); System.out.println("Today: " + formattedDate); System.out.println("Tomorrow: " + tomorrow.toString()); System.out.println("Yesterday: " + yesterday.toString()); } } <dependencies> <dependency> <groupId>moment</groupId> <artifactId>moment</artifactId> <version>1.0.0</version> </dependency> </dependencies>


上一篇:
下一篇:
切换中文