Java 时间显示


Java 时间显示

package pukepai;

import javax.xml.crypto.Data;
import java.lang.annotation.Target;
import java.text.SimpleDateFormat;
import java.util.Date;

public class test1
{

    public static void main(String args[])
    {
        TIme t1=new TIme();
        Thread play=new Thread(t1);
        play.start();


    }
}
class TIme implements Runnable
{
    int time=0;
    SimpleDateFormat m=new SimpleDateFormat("hh:mm:ss");
    Date date;

    public void run()
    {

        while(true)
        {
            date=new Date();
            System.out.println(date);
            System.out.println(m.format(date));
            System.out.println(time);
            time++;
            try
            {
                Thread.sleep(200);
            }
            catch (Exception e){}

        }
    }
}


文章作者: LHL
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 LHL !
评论
  目录