1 package sellwin.db; 2 3 import java.text.*; 4 import sellwin.utils.*; 5 6 10 11 16 public class DateUtils { 17 private static SimpleDateFormat mysqlFormatter = 18 new SimpleDateFormat("yyyy-MM-dd"); 19 private static SimpleDateFormat mysqlDateTimeFormatter = 20 new SimpleDateFormat("yyyy-MM-dd HH:mm"); 21 22 private static SimpleDateFormat oracleFormatter = 23 new SimpleDateFormat("dd-MMM-yy"); 24 private static SimpleDateFormat oracleDateTimeFormatter = 25 new SimpleDateFormat("dd-MMM-yyyy HH:mm"); 26 27 33 public static String format(int DB_TYPE, java.util.Date dt) { 34 if (DB_TYPE == Prefs.ORACLE) 35 return oracleFormatter.format(dt); 36 else 37 return mysqlFormatter.format(dt); 38 } 39 40 47 public static String formatDateTime(int DB_TYPE, java.util.Date dt) { 48 if (DB_TYPE == Prefs.ORACLE) 49 return "to_date('" + oracleDateTimeFormatter.format(dt) + "','dd-mon-yyyy hh24:mi')"; 50 else 51 return "'" + mysqlDateTimeFormatter.format(dt) + "'"; 52 } 53 } 54 | Popular Tags |