java.sql.date怎么用

2025-05-14 22:35:14

1、打开eclipse开发工具,项目中新建Java类DateFormat,勾选main主方法

java.sql.date怎么用

2、打开新建的Java类DateFormat,定义类方法queryCurrentDate,返回值为字符串

java.sql.date怎么用

3、在main主方法中,调用queryCurrentDate方法并赋值给date,并打印结果

java.sql.date怎么用

4、保存代码并使用Java Application运行,结果可以看到日期时间格式化

java.sql.date怎么用

5、调整queryCurrentDate方法中的值,直接返回st变量值

java.sql.date怎么用

6、再次调用queryCurrentDate方法,赋值给字符串变量time并打印

java.sql.date怎么用

7、再次保存代码并运行文件,可以看到当前格式化日期时间

java.sql.date怎么用
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢