List of utility methods to do SQL Date From
String | convertTime2String(long time) convert Time String return convertTS2String(new Timestamp(time)); |
Timestamp | convertTime2TS(long time) convert Time TS return new Timestamp(time); |
double | convertTimeToHour(long time) convert Time To Hour return convertTimeToDay(time) * 24;
|
Date | convertToDateTime(java.util.Date date, String time) convert To Date Time Calendar calendar = new GregorianCalendar(); String[] timeArray = getTime(time); calendar.setTime(date); calendar.set(Calendar.HOUR, Integer.parseInt(timeArray[0])); calendar.set(Calendar.MINUTE, Integer.parseInt(timeArray[1])); return new Date(calendar.getTime().getTime()); |
java.sql.Time | convertToTime(Date toDate) convert To Time java.sql.Time sql = null; sql = new java.sql.Time(toDate.getTime()); return sql; |
Time | convertToTime(java.util.Date date) Converts java.util.Date to java.sql.Time normalize year=1970,,month=1,day=1. if (date == null) { throw new IllegalArgumentException("date msut not be null"); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.YEAR, DEFUALT_YEAR); cal.set(Calendar.MONTH, 0); cal.set(Calendar.DAY_OF_MONTH, 1); ... |
TimeZone | getCNTimezone() get CN Timezone return TimeZone.getTimeZone("Asia/Shanghai"); |
String | getCurAllTime() RETURN DATE STRING FORMAT "yyyy-MM-dd HH:mm:ss" Timestamp ts = null; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String d = sdf.format(new java.util.Date()); ts = Timestamp.valueOf(d); } catch (Exception ex) { ex.printStackTrace(); return ts.toString().substring(0, 19); |
String | getCurrDateTime() get Curr Date Time java.sql.Timestamp date = new java.sql.Timestamp(System.currentTimeMillis()); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return formatter.format(date); |
String | getCurrentDateTime() get Current Date Time return getCurrentTime(DEFAULT_DATE_PATTERN);
|