TQC-JAVA 102-系統時間

使用以下格式顯示時間:
(1) 2003/5/7 上午 10:36
(2) 2003/5/7 上午 10:36:49
(3) 2003年5月7日 上午10時36分47秒
(4) 2003年5月7日 星期三 上午10時36分47秒

結果:

LocalTime  

程式碼: 

import java.util.*;
import java.text.DateFormat;
public class LocaleTime {
    static public void main(String[] args) {
        Locale tw = Locale.TAIWAN;
        for(int i=3;i>=0;i--){
            DateFormat dateFormat = DateFormat.getDateTimeInstance(i,i,tw);
            System.out.println(dateFormat.format(new Date()));
        }
    }
}

arrow
arrow
    全站熱搜

    李權益 發表在 痞客邦 留言(0) 人氣()