【Java开源代码栏目提醒】:网学会员为广大网友收集整理了,Usetime.java,希望对大家有所帮助!
package useBean;
import java.text.*;
import java.util.*;
public class Usetime{
/***************************************************
*method name: getddTime<br>
*method function: get system time<br>
*return value: String<br>
* yyyy/MM/dd<br>
*parameter explain: no<br>
*amend: crazyadept<br>
* 2004/8/4<br>
****************************************************/
public String getddTime(){
SimpleDateFormat formatter; // Formats the date displayed
Date currentDate; // Used to get date to display
String now; // String to hold date displayed
formatter = new SimpleDateFormat ("yyyy/MM/dd/", Locale.getDefault());
currentDate = new Date();
now = formatter.format(currentDate);
return now;
}
/***************************************************
*method name: getssTime<br>
*method function: get system time<br>
*return value: String<br>
* yyyy/MM/dd HH:mm:ss<br>
*parameter explain: no<br>
*amend: crazyadept<br>
* 2004/8/4<br>
****************************************************/
public String getssTime(){
SimpleDateFormat formatter; // Formats the date displayed
Date currentDate; // Used to get date to display
String now; // String to hold date displayed
formatter = new SimpleDateFormat ("yyyy/MM/dd/ HH:mm:ss", Locale.getDefault());
currentDate = new Date();
now = formatter.format(currentDate);
return now;
}
/***************************************************
*method name: gethhTime<br>
*method function: get system time<br>
*return value: String<br>
* HH:mm:ss<br>
*parameter explain: no<br>
*amend: crazyadept<br>
* 2004/8/14<br>
****************************************************/
public String gethhTime(){
SimpleDateFormat formatter; // Formats the date displayed
Date currentDate; // Used to get date to display
String now; // String to hold date displayed
formatter = new SimpleDateFormat ("HH:mm:ss", Locale.getDefault());
currentDate = new Date();
now = formatter.format(currentDate);
return now;
}
}