每日一算法4--将毫秒转化为日期
来源:互联网 发布:mac os 安装盘制作 编辑:程序博客网 时间:2024/05/22 05:21
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 Day4 {
public static void main(String[] args) {
new ConvertLong2Date().launchFrame();
}
public static class ConvertLong2Date extends Frame {
TextField tf = new TextField();
TextArea ta = new TextArea();
//主要方法,将毫秒转为日期
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("");
}
}
}
}
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 Day4 {
public static void main(String[] args) {
new ConvertLong2Date().launchFrame();
}
public static class ConvertLong2Date extends Frame {
TextField tf = new TextField();
TextArea ta = new TextArea();
//主要方法,将毫秒转为日期
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("");
}
}
}
}
0 0
- 每日一算法4--将毫秒转化为日期
- java将毫秒转化为日期
- 将当前日期的毫秒转化为字符串
- 毫秒数转化为日期时间格式
- java-将字符串和毫秒值转化为日期格式的几种方法
- 将毫秒值转化为时间(java)
- sql将毫秒数字转换为日期
- js将日期转换为毫秒值
- 将字符串转化为日期
- 将字符串转化为日期
- java 中将日期转换为毫秒 ,将毫秒转换为日期
- 怎样将毫秒转化为正确时间显示
- 是否为闰年,将毫秒数换转成日期类型
- PHP将日期转化为星期
- 如何将字符串转化为日期
- 毫秒值转化为时间
- 把时间转化为毫秒,把毫秒转化为时分秒
- 将日期转成毫秒数
- Android studio debug调试 解析
- ios在应用中调起qq聊天
- WampServer】怎样更改WampServer端口号
- Get 和 Post 的区别
- GD 库的使用
- 每日一算法4--将毫秒转化为日期
- 开机动画半屏、权限管理流程、hasSystemFeature
- 简单jxl的Excel读写操作
- 多线程的方法总结
- 回归基础之C语言程序1
- 网络(九)进程和线程
- 每天一个linux命令(1):ls
- 2、K近邻算法(KNN)
- 【wampserver】安装后访问localhost出现http403错误