快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

千龙国际娛乐_计算机等级考试将毫秒转化为日期



将毫秒转化为日期

import java.awt.BorderLayout;

import ja千龙国际娛乐va.awt.Frame;

import java.awt.TextArea;

import java.awt.TextField;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.ev千龙国际娛乐ent.WindowEvent;

import java.text.SimpleDateFormat;

import java.util.Date;

public class ConvertLong2Date extends Frame

{

Tex千龙国际娛乐tField tf = new TextField();

TextArea ta = new TextArea();

public static void main(String[] args)

{

new ConvertLong2Date().launchFrame();

}

public String convertL2D(long l)

{

long _l = 0L;

Date _d = null;

SimpleDateFormat _sdf = null;

String _s = null;

_l = l;

_d = new Date(_l);

_sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);

_s = _sdf.format(_d);

return _s;

}

public void launchFrame()

{

setLocation(300, 300);

setSize(480, 320);

setResizable(false);

add(tf,BorderLayout.SOUTH);

add(ta,千龙国际娛乐BorderLayout.NORTH);

pack();

tf.addActionListener(new tfActionListener());

this.setVisible(true);

this.addWindowListe千龙国际娛乐ner(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{

System.exit(0);

}

});

}

public class tfActionListener implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

long l = Long.parseLong(tf.getText());

ta.setText(new ConvertLong2Date().convertL2D(l));

tf.setText(“”);

}

}

}

您可能还会对下面的文章感兴趣: