/**
? * 格式化日期1
? * */
??? public static String formatTime( Calendar cal, String format ){
??????? SimpleDateFormat localTimeFormatter
??????????? = new SimpleDateFormat(format);
??????? return localTimeFormatter.format(cal.getTime());
??? }
??? /**
? * 格式化日期2
? * */
??? public static Calendar formatDate( String time, String format ){
??????? try{
??????????? Date d = new Date();
??????????? SimpleDateFormat timeFormatter1
??????????????? = new SimpleDateFormat(format);
??????????? d = timeFormatter1.parse(time);
??????????? Calendar cal = Calendar.getInstance();
??????????? cal.setTime(d);
??????????? return cal;
??????? }catch ( Exception ex ){
??????????? log.error("error: ", ex);
??????????? return Calendar.getInstance();
??????? }
??? }
? * 格式化日期1
? * */
??? public static String formatTime( Calendar cal, String format ){
??????? SimpleDateFormat localTimeFormatter
??????????? = new SimpleDateFormat(format);
??????? return localTimeFormatter.format(cal.getTime());
??? }
??? /**
? * 格式化日期2
? * */
??? public static Calendar formatDate( String time, String format ){
??????? try{
??????????? Date d = new Date();
??????????? SimpleDateFormat timeFormatter1
??????????????? = new SimpleDateFormat(format);
??????????? d = timeFormatter1.parse(time);
??????????? Calendar cal = Calendar.getInstance();
??????????? cal.setTime(d);
??????????? return cal;
??????? }catch ( Exception ex ){
??????????? log.error("error: ", ex);
??????????? return Calendar.getInstance();
??????? }
??? }
posted on 2007-02-07 10:59 張金鵬 閱讀(220) 評(píng)論(0) 編輯 收藏 所屬分類(lèi): core java中的一些數(shù)據(jù)結(jié)構(gòu)的處理