SUN认证 百分网手机站

Java中将毫秒转化为日期的方法

时间:2017-10-16 11:17:33 SUN认证 我要投稿

Java中将毫秒转化为日期的方法

  将毫秒转化为日期

  import java.awt.BorderLayout;

  import java.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.event.WindowEvent;

  import java.text.SimpleDateFormat;

  import java.util.Date;

  public class ConvertLong2Date extends Frame

  {

  TextField 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.addWindowListener(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(“”);

  }

  }

  }

【Java中将毫秒转化为日期的方法】相关文章:

1.Java中日期的处理方法

2.Java动态代理实现AOP的方法

3.Java线程同步的方法

4.Java读取xml文件的方法

5.Java编程节省内存的方法

6.跟踪Java执行过程的方法

7.DB2日期格式更改的方法

8.使用sql语句查询日期的方法