mytime.java

来自「jsp网上书店系统(论文+源程序).rar JSP开发的」· Java 代码 · 共 88 行

JAVA
88
字号
package BookShop;

import java.text.*;
import java.util.*;

public class MyTime{

	/***************************************************
	*method name:	getDay<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 getDay(){
		
    	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:	getYear<br>
	*method function:	get system time<br>
	*return value:  String<br>
	*		   		yyyy/MM/dd HH:mm<br>
	*parameter explain:	no<br>
	*amend:	crazyadept<br>
	*		2004/8/4<br>
	****************************************************/
	public String getYear(){
	
    	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", Locale.getDefault());
        currentDate = new Date();
        now = formatter.format(currentDate);
		return now;
	}

	/***************************************************
	*method name:	getSecond<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 getSecond(){
	
    	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;
	}
	
	/***************************************************
	*method name:	getId<br>
	*method function:	get system time be use to id<br>
	*return value:  String<br>
	*		   		yyyyMMddHHmmss<br>
	*parameter explain:	no<br>
	*amend:	crazyadept<br>
	*		2004/8/20<br>
	****************************************************/

	public String getId(){
		
    	SimpleDateFormat formatter;  // Formats the date displayed
	    Date currentDate;            // Used to get date to display
	    String now;             // String to hold date displayed
        formatter = new SimpleDateFormat ("yyMMddHHmmss", Locale.getDefault());
        currentDate = new Date();
        now = formatter.format(currentDate);
		return ("HY"+now);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?