Java Hutool工具类获取年-月拼接字符串
使用Hutool工具类获取年和月的拼接字符串可以使用DateUtil类的format方法。具体实现如下:\n\njava\nimport cn.hutool.core.date.DateUtil;\n\npublic class Main {\n public static void main(String[] args) {\n String yearAndMonth = DateUtil.format(DateUtil.date(), "yyyy-MM");\n System.out.println(yearAndMonth);\n }\n}\n\n\n输出结果为当前年月的拼接字符串,例如:2022-01
AI 优化版
原文地址:https://www.cveoy.top/t/topic/qbmB 著作权归作者所有。请勿转载和采集!