1 6 7 package com.quikj.application.communicator.admin.controller; 8 9 import java.util.*; 10 11 15 public class DateUtility 16 { 17 public static Date processInputDate(String date) { 19 return processInputDate(date, 0, 0, 0); 20 } 21 22 public static Date processInputDate(String date, int hr, int min, int sec) { 24 if ((date == null) || (date.length() != 10)) 25 { 26 return null; 27 } 28 29 try 30 { 31 Calendar cal = Calendar.getInstance(); 32 cal.setLenient(false); 33 cal.set(Calendar.YEAR, Integer.parseInt(date.substring(6))); 34 cal.set(Calendar.MONTH, Integer.parseInt(date.substring(0,2)) - 1); 35 cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(date.substring(3,5))); 36 cal.set(Calendar.HOUR_OF_DAY, hr); 37 cal.set(Calendar.MINUTE, min); 38 cal.set(Calendar.SECOND, sec); 39 40 return cal.getTime(); 41 } 42 catch(NumberFormatException ex) 43 { 44 } 45 catch (IllegalArgumentException ex1) 46 { 47 } 48 return null; 49 } 50 51 } 52 | Popular Tags |