📄 timemaker.java
字号:
/**
* Copyright (C) 2003-2006 TiandiNet.com
*
* Struts 文章系统 1.1
*
* release-date: 2006-02-25
*/
package com.tiandinet.StrutsArticle.Utils;
import java.util.*;
/**
* @author Meng Yang
* @version 1.1
*/
public class TimeMaker
{
private int year,month,day,hour12,hour24,minute,second;
private String formatTime;
public void makeTime(long time)
{
Calendar cal = Calendar.getInstance();
//为兼容PHP网络学院,PHP网络学院中使用秒,在此处转换为毫秒
if(String.valueOf(time).length() < 13)
{
time = time * 1000;
}
if(time <= 0L)
{
cal.setTime(new Date());
}
else
{
cal.setTime(new Date(time));
}
this.year = cal.get(Calendar.YEAR);
this.month = cal.get(Calendar.MONTH)+1;
this.day = cal.get(Calendar.DATE);
this.hour12 = cal.get(Calendar.HOUR);
this.hour24 = cal.get(Calendar.HOUR_OF_DAY);
this.minute = cal.get(Calendar.MINUTE);
this.second = cal.get(Calendar.SECOND);
String tY,tMon,tD,tH12,tH24,tMin,tS;
tY = String.valueOf(this.year);
tMon = String.valueOf(this.month);
tD = String.valueOf(this.day);
tH12 = String.valueOf(this.hour12);
tH24 = String.valueOf(this.hour24);
tMin = String.valueOf(this.minute);
tS = String.valueOf(this.second);
tMon = (tMon.length() == 1)?("0"+tMon):tMon;
tD = (tD.length() == 1)?("0"+tD):tD;
tH12 = (tH12.length() == 1)?("0"+tH12):tH12;
tH24 = (tH24.length() == 1)?("0"+tH24):tH24;
tMin = (tMin.length() == 1)?("0"+tMin):tMin;
tS = (tS.length() == 1)?("0"+tS):tS;
this.formatTime = tY + "-" + tMon + "-" + tD + " " + tH24 + ":" + tMin + ":" + tS;
}
public String getFormatTime()
{
return this.formatTime;
}
public int getYear(){return this.year;}
public int getMonth(){return this.month;}
public int getDay(){return this.day;}
public int getHour12(){return this.hour12;}
public int getHour24(){return this.hour24;}
public int getMinute(){return this.minute;}
public int getSecond(){return this.second;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -