您当前的位置: 首页 >  哆啦A梦_i Java

Java: 格式化时间(SimpleDateFormat)

哆啦A梦_i 发布时间:2020-03-23 15:53:12 ,浏览量:4

如何使用 SimpleDateFormat 类的 format(date) 方法来格式化时间,如下所示:

package csdn1;
import java.text.SimpleDateFormat;
import java.util.Date;
public class 时间csdn1 {
    public static void main(String[] args){ 
        Date date = new Date();
        String strDateFormat = "yyyy-MM-dd HH:mm:ss"; 
        SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); 
        System.out.println(sdf.format(date)); 
    }
}

运行结果为:

2020-03-23 15:43:23

关注
打赏
查看更多评论

哆啦A梦_i

暂无认证

  • 4浏览

    0关注

    566博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录