java 标准日期格式

1
2
3
4
5
6
7
8
9
10
public static void main(String[] argv) {
    // 使用默认时区和语言环境获得一个日历
    Calendar cale = Calendar.getInstance();
    // 将 Calendar 类型转换成 Date 类型
    Date tasktime = cale.getTime();
    // 设置日期输出的格式
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // 格式化输出
    System.out.println(df.format(tasktime));  // 2017-12-11 15:05:07
}

  

public static void main(String[] argv) {// 使用默认时区和语言环境获得一个日历Calendar cale = Calendar.getInstance();// 将 Calendar 类型转换成 Date 类型Date tasktime = cale.getTime();// 设置日期输出的格式SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化输出System.out.println(df.format(tasktime));}

posted @   newXin  阅读(5914)  评论(0编辑  收藏  举报
编辑推荐:
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
阅读排行:
· 用 DeepSeek 给对象做个网站,她一定感动坏了
· DeepSeek+PageAssist实现本地大模型联网
· 手把手教你更优雅的享受 DeepSeek
· 腾讯元宝接入 DeepSeek R1 模型,支持深度思考 + 联网搜索,好用不卡机!
· 从 14 秒到 1 秒:MySQL DDL 性能优化实战
点击右上角即可分享
微信分享提示