java Date Converter
String Date to Long Time Stamp Type
private Long convertTimeStampToDate(String yy, String MM, String dd, String hh, String mm, String ss) { String result = ""; Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(date);
int currHour = cal.get(Calendar.HOUR_OF_DAY); int currMin = cal.get(Calendar.MINUTE); int currSec = cal.get(Calendar.SECOND);
if((yy==null) || (MM==null) || (dd==null)) { displayWarning("error input date"); return null; } result = "20" + yy + MM + dd;
if((hh!=null) && (hh.length() == 2)) result += hh; else result += currHour;
if((mm!=null) && (mm.length() == 2)) result += mm; else result += currMin;
if((ss!=null) && (ss.length() == 2)) result += ss; else result += currSec;
DateFormat dfm = new SimpleDateFormat("yyyyMMddHHmmss"); dfm.setTimeZone(TimeZone.getTimeZone("Asia/Seoul")); try { long val = dfm.parse(result).getTime(); return (val/1000); } catch (Exception e) { return 0L; } } |