package mechendddate
import javatextParseExceptionimport javatextSimpleDateFormatimport javautilCalendarimport javautilDate
import javaxswingtextStyleContextSmallAttributeSet
public class TestDate {
public static void main(String[] args) throws ParseException {
Date now = new Date()//取運行的時間Systemoutprintln(now)
long s = SystemcurrentTimeMillis()//取當前據 所過的毫秒數for(int i = i <= i++) {
} long e = SystemcurrentTimeMillis()Systemoutprintln(es)
SimpleDateFormat sdf = new SimpleDateFormat(yyyymmdd hhmmss)//將Date轉換為特定的格式String str = sdfformat(now)Systemoutprintln(str)
String ss = Date d = sdfparse(ss)//將特定格式日期轉換為Date Systemoutprintln(d)
Calendar n = CalendargetInstance()//獲取它的實例注意是抽象類不能用new Systemoutprintln(n)nset( )//設定日期// int today = ngetTime()getDay()Systemoutprintln(ngetTime())int dd = nDAY_OF_WEEK//是該周的第幾天Systemoutprintln(dd)}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26402.html