package th.co.muangthai.endrprint.util; import sun.org.mozilla.javascript.internal.Callable; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; public class DateUtil { public static int compareDate(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new RuntimeException("invalid parameter date !!"); } Calendar cal = Calendar.getInstance(); cal.setTime(date1); // cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); date1 = cal.getTime(); cal.setTime(date2); // cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); date2 = cal.getTime(); // return date1.compareTo(date2); return date1.getTime() < date2.getTime() ? -1 : date1.getTime() > date2.getTime() ? 1 : 0; } public static Date toDate(String stringDate) throws ParseException { return DateUtil.toDate(stringDate, VSMUtil.FORMAT_DATE); } public static String toFormatString(Date date, String pattern) throws ParseException { String convertedDate = null; if (VSMUtil.isNotEmpty(date)) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); convertedDate = dateFormat.format(date); } return convertedDate; } public static String toFormatString(Date date) throws ParseException { return DateUtil.toFormatString(date, VSMUtil.FORMAT_DATE); } public static String toFormatStringWeb(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(VSMUtil.FORMAT_DATE, VSMUtil.LOCALE); String dateStr = dateFormat.format(date); return dateStr; } return ""; // String dateStr = DateUtil.toFormatString(date, DEFAULT_PATTERN); // return dateStr == null? "" : dateStr; } public static String toFormatStringThai(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", VSMUtil.LOCALE); String dateStr = dateFormat.format(date); return dateStr; } return ""; // String dateStr = DateUtil.toFormatString(date, DEFAULT_PATTERN); // return dateStr == null? "" : dateStr; } public static String toFormatStringWebEN(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(VSMUtil.FORMAT_DATE, VSMUtil.LOCALE_EN); String dateStr = dateFormat.format(date); return dateStr; } return ""; // String dateStr = DateUtil.toFormatString(date, DEFAULT_PATTERN); // return dateStr == null? "" : dateStr; } public static String toFormatStringWebTh(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", VSMUtil.LOCALE); String dateStr = dateFormat.format(date); return dateStr; } return ""; } public static String toFormatStringWebTh2(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd", VSMUtil.LOCALE_EN); String dateStr = dateFormat.format(date); return dateStr; } return ""; } public static Integer toFormatDateDDtoInt(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd", VSMUtil.LOCALE_EN); String dateStr = dateFormat.format(date); Integer dateInt = Integer.parseInt(dateStr); return dateInt; } return null; } public static Date toDate(String stringDate, String pattern) throws ParseException { Date convertedDate = null; if (VSMUtil.isNotEmpty(stringDate)) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.US); convertedDate = dateFormat.parse(stringDate); } else { throw new RuntimeException("Argument Date string can't be empty."); } return convertedDate; } public static java.sql.Date toSqlDate(Date date) { if (date == null) { return null; } return new java.sql.Date(date.getTime()); } public static java.sql.Date toSqlDate(String date) throws ParseException { if (date == null) { return null; } return new java.sql.Date(DateUtil.toDate(date).getTime()); } public static Date convertToBC(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); if ("Thai".equals(VSMUtil.LOCALE.getDisplayLanguage())) { c.add(Calendar.YEAR, -543); date = c.getTime(); } return date; } public static Date plusOneDay(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.add(Calendar.DATE, +1); date = c.getTime(); return date; } public static Date convertACToBC(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); if ("Thai".equals(VSMUtil.LOCALE.getDisplayLanguage())) { c.add(Calendar.YEAR, +543); date = c.getTime(); } return date; } public static String getDayInWeekThai(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); switch (c.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: return "อาทิตย์"; case Calendar.MONDAY: return "จันทร์"; case Calendar.TUESDAY: return "อังคาร"; case Calendar.WEDNESDAY: return "พุธ"; case Calendar.THURSDAY: return "พฤหัสบดี"; case Calendar.FRIDAY: return "ศุกร์"; case Calendar.SATURDAY: return "เสาร์"; } return null; } public static String getDateThai(Date date){ if(VSMUtil.isNotEmpty(date)) { String pattern = "dd MMMM yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(pattern,new Locale("th","th")); String xx = sdf.format(Calendar.getInstance().getTime()); //System.out.println(sdf.format(Calendar.getInstance().getTime())); return xx; } return null; } public static String getDateEn(String date) throws ParseException { if (VSMUtil.isNotEmpty(date)) { String[] aa = date.split("/"); String dd = aa[2].trim(); if (Integer.parseInt(dd) > 2500) { Integer y = Integer.parseInt(dd) - 543; aa[2] = y.toString(); } String xx = aa[0] + "/" + aa[1] + "/" + aa[2]; // System.out.println(xx); return xx; } return null; } public static String getDateShortTh(String date) throws ParseException { if (VSMUtil.isNotEmpty(date)) { String[] aa = date.split("/"); String dd = aa[2].trim(); if (Integer.parseInt(dd) < 2500) { Integer y = Integer.parseInt(dd) + 543; aa[2] = y.toString(); } String xx = aa[0] + "/" + aa[1] + "/" + aa[2]; // System.out.println(xx); return xx; } return null; } public static String getMonthYearThai(Date date){ if(VSMUtil.isNotEmpty(date)) { String pattern = "MMMM yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(pattern,new Locale("th","th")); String xx = sdf.format(Calendar.getInstance().getTime()); //System.out.println(sdf.format(Calendar.getInstance().getTime())); return xx; } return null; } public static String getMonthThaiYearEn(Date date)throws ParseException{ if(VSMUtil.isNotEmpty(date)) { String patternM = "MMMM"; String patternY = "yyyy"; SimpleDateFormat sdfM = new SimpleDateFormat(patternM,new Locale("th","th")); SimpleDateFormat sdfY = new SimpleDateFormat(patternY,new Locale("en","en")); String Month = sdfM.format(date); String Year = sdfY.format(date); return Month+" "+Year; } return null; } public static String getYearThai(Date date)throws ParseException{ if(VSMUtil.isNotEmpty(date)) { String patternDM = "dd/MM/"; String patternY = "yyyy"; SimpleDateFormat sdfDM = new SimpleDateFormat(patternDM,new Locale("en","en")); SimpleDateFormat sdfY = new SimpleDateFormat(patternY,new Locale("th","th")); String Month = sdfDM.format(date); String Year = sdfY.format(date); return Month+""+Year; } return null; } public static String getYearThaiOnly(Date date)throws ParseException{ if(VSMUtil.isNotEmpty(date)) { String patternY = "yyyy"; SimpleDateFormat sdfY = new SimpleDateFormat(patternY,new Locale("th","th")); String Year = sdfY.format(date); return Year; } return null; } public static String getMonthThai(Date date){ if(VSMUtil.isNotEmpty(date)) { String pattern = " MMMM "; SimpleDateFormat sdf = new SimpleDateFormat(pattern,new Locale("th","th")); String xx = sdf.format(date); //System.out.println(sdf.format(Calendar.getInstance().getTime())); return xx; } return null; } public String showDateTHDaz(String date, int style) { Calendar c = new GregorianCalendar(); String[] sDate = date.split("-"); c.set(Integer.parseInt(sDate[0]), Integer.parseInt(sDate[1]) - 1, Integer.parseInt(sDate[2])); java.util.Date d = c.getTime(); int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL }; DateFormat df = DateFormat.getDateInstance(styles[style], new Locale("th", "TH")); String result = df.format(d); return result; } public String showDateTHSlash(String date, int style) { Calendar c = new GregorianCalendar(); String[] sDate = date.split("-"); if(sDate.length < 3){ sDate = date.split("/"); } c.set(Integer.parseInt(sDate[2]) >= 2500 ? Integer.parseInt(sDate[2])-543:Integer.parseInt(sDate[2]), Integer.parseInt(sDate[1]) - 1, Integer.parseInt(sDate[0])); java.util.Date d = c.getTime(); int[] styles = { DateFormat.DEFAULT, DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL }; DateFormat df = DateFormat.getDateInstance(styles[style], new Locale("th", "TH")); String result = df.format(d); return result; } public void writeFile(byte[] data, String fileName) throws IOException { OutputStream out = new FileOutputStream(fileName); out.write(data); out.close(); } public static String getBankAccountFormat(String number){ if(VSMUtil.isNotEmpty(number)) { String xx= String.format("%s-%s-%s-%s", number.substring(0, 3), number.substring(3, 4), number.substring(4, 9),number.substring(9, 10)); return xx; } return null; } public static String getBankAccountFormat12Digit(String number){ if(VSMUtil.isNotEmpty(number)) { /*00-000-5-01050-3*/ String xx= String.format("%s-%s-%s-%s-%s", number.substring(0, 2), number.substring(2, 5), number.substring(5, 6),number.substring(7, 11),number.substring(11,12)); return xx; } return null; } public static String getBankAccountFormat14Digit(String number){ if(VSMUtil.isNotEmpty(number)) { /*000-11300000079*/ String xx= String.format("%s-%s", number.substring(0, 3), number.substring(3, 14)); return xx; } return null; } public static String getDecimalFormat(BigDecimal number) { if(VSMUtil.isNotEmpty(number)) { DecimalFormat dc = new DecimalFormat("#,##0.00"); String xx= dc.format(number); return xx; } return null; } public static String getDecimalFormatNoDot(int number) { if(VSMUtil.isNotEmpty(number)) { DecimalFormat dc = new DecimalFormat("#,##0"); String xx= dc.format(number); return xx; } return null; } public static Date getMaxDateOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); return calendar.getTime(); } public static Date getFirstDateOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); return calendar.getTime(); } public static Date getMaxDateOfDay(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); return calendar.getTime(); } public static String getSQLToDate(Date date) { if (date == null) { return null; } try { return "to_date('" + DateUtil.toFormatString(date, "dd/MM/yyyy") + "', 'dd/mm/yyyy')"; } catch (ParseException e) { return null; } } public static Date formatDateForPOI(String setDate) throws ParseException { Date paymentDate = new Date(); try{ paymentDate = DateUtil.toDate(setDate,"dd/MM/yy"); /*DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy"); Date date = formatter.parse(setDate); Calendar cal = Calendar.getInstance(); cal.setTime(date); if(cal.get(Calendar.YEAR) > 2500){ cal.add(Calendar.YEAR,-543); } paymentDate = cal.getTime();*/ return paymentDate; } catch (ParseException e) { return null; } } public static String convertedToYMD(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", VSMUtil.LOCALE_EN); String dateStr = dateFormat.format(date); return dateStr; } return ""; } public static String convertedToYMDSubToNumber(Date date , Integer sub) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", VSMUtil.LOCALE_EN); String dateStr = dateFormat.format(date); Integer ans = Integer.parseInt(dateStr) - sub; return ans.toString(); } return ""; } public static Date convertedDateWS2Lof4Post(String as400StrDate) throws ParseException { // ddmmYYYY => 01122557 Date dateReturn = null; if(VSMUtil.isNotEmpty(as400StrDate)){ String dd = as400StrDate.substring(0,2); String mm = as400StrDate.substring(2,4); String yy = as400StrDate.substring(4,8); int yyyy = Integer.parseInt(yy) - 543; String strDate = dd+"/"+mm+"/"+yyyy; SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.US); try { dateReturn = dateFormat.parse(strDate); } catch (Exception e) { e.printStackTrace(); } } return dateReturn; } public static String convertedDateLof4Post2WS(Date dateLof4post) throws ParseException { // ddmmYYYY => 01122557 String dateReturn = null; if(VSMUtil.isNotEmpty(dateLof4post)){ String date = DateUtil.toFormatString(dateLof4post,"ddMMyyyy"); //System.out.println(date); String mm = date.substring(0,4); String yy = date.substring(4,8); int yyyy = Integer.parseInt(yy) + 543; dateReturn = mm+yyyy; } return dateReturn; } public static BigDecimal getAgeYY(Date dateStar) throws ParseException { // ddmmYYYY => 01122557 int dateReturn = 0; if(VSMUtil.isNotEmpty(dateStar)){ long diffTime = new Date().getTime() - dateStar.getTime(); long diffDay = (diffTime / (24*60*60*1000))/365; dateReturn = Integer.parseInt("" + diffDay); return new BigDecimal(dateReturn+""); } return null; } public static BigDecimal getAgeYYFromIssuedData(Date dateStar ,Date dateEnd) throws ParseException { // ddmmYYYY => 01122557 int dateReturn = 0; if(VSMUtil.isNotEmpty(dateStar) && VSMUtil.isNotEmpty(dateEnd) ){ long diffTime = dateEnd.getTime() - dateStar.getTime(); //long diffDay = (diffTime / (24*60*60*1000))/365; long diffDay2 = (dateEnd.getYear() - (dateStar.getYear())); dateReturn = Integer.parseInt("" + diffDay2); if (dateReturn==0){ return new BigDecimal("1"); }else { return new BigDecimal(dateReturn+""); } } return null; } public static BigDecimal getAgeDD(Date dateStar ,Date dateEnd) throws ParseException { // ddmmYYYY => 01122557 int dateReturn = 0; if(VSMUtil.isNotEmpty(dateStar) && VSMUtil.isNotEmpty(dateEnd) ){ long diffTime = dateEnd.getTime() - dateStar.getTime(); long diffDay = (diffTime / (24*60*60*1000)); return new BigDecimal(diffDay+""); } return null; } public static XMLGregorianCalendar toXMLGregorianCalendar(Date date){ XMLGregorianCalendar xmlCalendar = null; if(VSMUtil.isNotEmpty(date)) { GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(date); try { xmlCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCalendar); } catch (DatatypeConfigurationException ex) { // } } return xmlCalendar; } public static Date toDate(XMLGregorianCalendar calendar){ if(calendar == null) { return null; } try { return calendar.toGregorianCalendar().getTime(); } catch (Exception ex) { return null; } } public static Date add(String formatter, int num, Date d_date) { GregorianCalendar d0= new GregorianCalendar(); d0.setTime(d_date); if ("dd".equals(formatter)) { d0.add(Calendar.DAY_OF_MONTH, num); } if ("mm".equals(formatter)) { d0.add(Calendar.MONTH, num); } if ("yy".equals(formatter)) { d0.add(Calendar.YEAR, num); } if ("ww".equals(formatter)) { d0.add(Calendar.DAY_OF_MONTH, num*7); } if ("hh".equals(formatter)) { d0.add(Calendar.HOUR, num); } if ("mi".equals(formatter)) { d0.add(Calendar.MINUTE, num); } if ("ss".equals(formatter)) { d0.add(Calendar.SECOND, num); } return d0.getTime(); } public static int getNumMaxDateInMonth(Date date){ Calendar calendar = new GregorianCalendar(); calendar.setTime( date ); return calendar.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); } public static int getNumDateInMonth(Date date){ Calendar calendar = new GregorianCalendar(); calendar.setTime( date ); return calendar.get(Calendar.DAY_OF_MONTH); } public static Date getLastDateInMonth(Date date){ int numDateInMonth = getNumMaxDateInMonth( date ); int numDateInDate = getNumDateInMonth( date ); int addDate = numDateInDate * -1; Date dateFrom = add("dd" , addDate , date ); return add("dd", numDateInMonth, dateFrom) ; } public static String convertToBCCheckLocal(Date date) throws ParseException { String strDate = ""; Calendar c = Calendar.getInstance(); c.setTime(date); if ("TH".equals(VSMUtil.LOCALE.getCountry())) { c.add(Calendar.YEAR, -543); date = c.getTime(); } strDate = DateUtil.toFormatString(date,"dd/MM/yyyy"); return strDate; } public static String convertToBCCheckLocal2(Date date) throws ParseException { String strDate = ""; Calendar c = Calendar.getInstance(); c.setTime(date); if ("TH".equals(VSMUtil.LOCALE.getCountry())) { c.add(Calendar.YEAR, -543); date = c.getTime(); } strDate = DateUtil.toFormatString(date,"yyyyMMdd"); return strDate; } public static String toFormatStringWebTh3(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(VSMUtil.FORMAT_DATE , VSMUtil.LOCALE); String dateStr = dateFormat.format(date); return dateStr; } return ""; } public static Date toTrimDate(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(VSMUtil.FORMAT_DATE); String dateStr = dateFormat.format(date); return toDate(dateStr); } return null; } public static Date toDateEng(Date date) throws ParseException { if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(VSMUtil.FORMAT_DATE, VSMUtil.LOCALE_EN); String dateStr = dateFormat.format(date); return toDate(dateStr); } return null; } public static Date toDateEngByDateTh(Date date) throws ParseException { if (date != null) { Date b = add("yy", -543, date); return b; } return null; } public static Date toDateEngByDateTh(Calendar date) throws ParseException { if (date != null) { Date b = add("yy",-543,date.getTime()); return b; } return null; } public static Date getDateEn4DateTh(String date) throws ParseException { if (VSMUtil.isNotEmpty(date)) { String[] aa = date.split("/"); String dd = aa[2].trim(); Integer y = Integer.parseInt(dd) - 543; aa[2] = y.toString(); String xx = aa[0] + "/" + aa[1] + "/" + aa[2]; // System.out.println(xx); return toDate(xx,"dd/MM/yyyy"); } return null; } public static int compareToDate(Date dateForm , Date dateTo){ if(VSMUtil.isEmpty(dateForm)){ return 2; }else if(VSMUtil.isEmpty(dateTo)){ return -2; } return dateForm.compareTo(dateTo); } /*public static void main(String args[]) throws ParseException { DateUtil serviceDate = new DateUtil(); Date date = new Date(); //00-000-5-01050-3 String xx = serviceDate.getYearThai(date); System.out.println("----->"+xx); }*/ /*public static void main(String args[]) throws ParseException { Date now =new Date(); getDateEn("07/04/2013"); //System.out.println(DateUtil.getMaxDateOfMonth(DateUtil.toDate("01/02/2012"))); // System.out.println(DateUtil.getMonthThai(DateUtil.toDate("01/03/2012"))); }*/ /*public static void main(String[] args) { try { Date input = DateUtil.toDate("28/06/2012"); Date now = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(now); cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date today = cal.getTime(); // System.out.println("input : " + input); // System.out.println("now : " + now); // System.out.println("today : " + today); // System.out.println("compare : " + input.compareTo(today)); Date input1 = DateUtil.toDate("29/06/2012"); Date input2 = DateUtil.toDate("29/06/2012"); System.out.println("compare : " + DateUtil.compareDate(input1, input2)); } catch (ParseException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }*/ public static Calendar DateToCalendar(Date date ) { Calendar cal = null; try { DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); date = (Date)formatter.parse(date.toString()); cal=Calendar.getInstance(); cal.setTime(date); } catch (ParseException e) { System.out.println("Exception :"+e); } return cal; } public static Date addOneDay(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.add(Calendar.DATE, -1); date = c.getTime(); return date; } public static String formatTimeQuartz(String time){ StringBuilder str = new StringBuilder(time); String strInTime = null; String hh = null; String mm = null; String ss = null; if(VSMUtil.isNotEmpty(time)){ String[] inTime = time.split(":"); hh = inTime[0]; mm = inTime[1]; ss = inTime[2]; strInTime = ss+" "+mm+" "+hh+" * * ?"; } return strInTime; } public static Date formatSetDateTime24HrsEn(Date date , String time){ int HH = 0; int mm = 0; int ss = 0; int ms = 0; if(VSMUtil.isNotEmpty(time)){ HH = Integer.parseInt(time.substring(0, 2)); mm = Integer.parseInt(time.substring(3, 4)); ss = Integer.parseInt(time.substring(5, 6)); } Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY,HH); cal.set(Calendar.MINUTE,mm); cal.set(Calendar.SECOND,ss); cal.set(Calendar.MILLISECOND,ms); Date d = cal.getTime(); return d; } public static void main(String[] args) { try { //System.out.println(toFormatString(formatSetDateTime24HrsEn(DateUtil.toDate("09/11/2015"),"220000"),"yyyy-MM-dd HH:mm:ss")); //System.out.println(DateUtil.toDate("25-11-2013 01:00:01", "dd-MM-yyyy")); //System.out.println(DateUtil.toFormatStringWebTh(new Date())); //System.out.println(DateUtil.toFormatString(new Date(), "yyyyMMdd HHmmss")); //System.out.println(DateUtil.getLastDateInMonth(new Date())); //PosRuleWsServicePS vvv = new PosRuleWsServicePS(); //vvv.doBRMSChkPosRule("188","1","LOF4POS","-371","NPHAI"); /*Date f = new Date(); for(int i=0;i<10;i++){ System.out.println(DateUtil.toFormatString(f, "yyyyMMdd HHmmss")); f = add("ss",1,f); }*/ // Date bb = toDate("01/02/2558","dd/MM/yyyy"); //Calendar bbf = bb. // System.out.println(DateUtil.formatTimeQuartz("23:48:49")); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }