www.pudn.com > lucene_book(1).rar > DateWrapper.java, change:2006-12-12,size:724b


package test; 
 
import java.text.SimpleDateFormat; 
import java.util.Date; 
 
public class DateWrapper { 
	 
	private String format = null; 
 
	private Date date = null; 
 
	private SimpleDateFormat sf = null; 
 
	public DateWrapper() throws Exception { 
	} 
 
	public String output(String format) { 
		date = new Date(); 
		sf = new SimpleDateFormat(format); 
		return sf.format(date); 
	} 
	 
	public static void main (String [] args) throws Exception{ 
		DateWrapper wrapper = new DateWrapper(); 
		System.out.println("yyyy-MM-dd : " + wrapper.output("yyyy-MM-dd")); 
		System.out.println("yyyy-MM-dd hh:mm:ss : " + wrapper.output("yyyy-MM-dd hh:mm:ss")); 
	} 
 
	public String getFormat() { 
		return format; 
	} 
 
}