JAVA基础—关于Date

来源:互联网 发布:白话文翻译文言文软件 编辑:程序博客网 时间:2024/06/06 12:29
package com.fwj.reitheima;import java.text.SimpleDateFormat;import java.util.Date;public class DateDome {public static void main(String[] args) {Date d= new Date();System.out.println(d);//打印的时间看不懂,希望有些格式。//将模式封装到SimpleDateformat对象中。SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日    hh:mm:ss");//调用format方法让模式格式化指定Date对象。String time = sdf.format(d);System.out.println("time: "+time);long l= System.currentTimeMillis();String NowTime=sdf.format(l);System.out.println(NowTime);}}


0 0
原创粉丝点击