|
Date Validation is the one the common task for all the web development. But, We are writing the code for every project Here i just share you my code which have standard date utilities. so Java Geeks just stop writing again and again date Validation and Date manipulation methods. Just use this below Class
Features
l -Dates can be Validation Performed:
l -Getting current date and Time using methods.
l -Validation of typed in dates - eg 2001/02/29 won’t be accepted. Knows leap years.
l -Allowed input formats are: American mm/dd/yyyy (12/31/2003), European dd.mm.yyyy (31.12.2003), ISO -yyyy-mm-dd (2003-12-31) and Japan yyyy/mm/dd (2009/03/03).
l -Display format can be one of American, European etc.,.
Functions in DateUtils.
getCurrentDate():
Returns Date. Pattern for date: yyyyMMdd.
getCurrentDateFormat():
Returns Date. Pattern for date: yyyy/MM/dd
getPreviousDate ():
Returns Previous Date. Pattern for date: yyyyMMdd.
getCurrentDateDD()
Returns Current Date. Pattern for date: dd.
getCurrentDay()
Returns Current Day
getCurrentDateYM()
Returns Current Year&Month. Pattern for date: yyyyMM.
getCurrentMonth()
Returns Current Month. Pattern for date: MM.
getCurrentYear()
Returns Current Year. Pattern for date: yyyy.
getCurrentTime()
Returns Current Time. Pattern for Time: HHmmssSSS.
getCurrentTimeHMS()
Returns Current Time. Pattern for Time: HHmmss.
getCurrentTimeHM()
Returns Current Time. Pattern for Time: HHmm.
getCurrentTimeStamp()
Returns Current Timestamp.
getYMD(String date, String pattern)
Returns Date in YYYYMMDD Format.
getYM(String date, String pattern)
Returns Year&Month in YYYYMM Format.
SimpleDateFormat getDateFormat(String pattern)
Returns YYYYMMDD Format.
isDateYear(String yyyymmdd)
Validates Date and returns Date
isYM(String yyyymm)
Validates Year&Month and returns Year&Month
isTimeHM(String strTime)
Validates Time and returns Time
isDateYYYYMMDD(String strDate)
Validates Date and returns Boolean
isDateYYYYMM(String strDate)
Validates Year&Month and returns Boolean
isTimeHHMM(String strTime)
Validates Time and returns Boolean
setDate(String strValue)
Validates Date and returns yyyyMMDD format
getDate(String strValue)
Validates Date and returns yyyy/MM/DD format
setYM(String strValue)
Validates Year&Month and returns yyyyMM format
getYM(String strValue)
Validates Year&Month and returns yyyy/MM format
setTime(String strValue)
Validates Time and returns HHMM format
getTime(String strValue)
Validates Time and returns HH:MM format
isNumber(String strInput)
Check given String is Number
isDecimal(String strInput)
Check given String is Decimal
isValidDate(String strDate)
Validates Date and returns Boolean
isValidYM(String strDate)
Validates Year&Month and returns Boolean
isValidTimeHM(String strTime)
Validates Time and returns Boolean
CompareDate(String strFromDate, String strToDate)
Compares two date and returns Boolean
How Can Use Methods?
DateUtils class all methods are written as static method. Call method following way
DateUtils.MethodName();
For example,
DateUtils.getCurrentDate();
DateUtils.isNumber(StrValue);
DateUtils.isValidaYYYYMMDD(strDate);
Use this Program for your Date Manipulations.
import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar;
public abstract class DateUtils{
public static final long TIME_IN_MILLI_SECONDS = 24 * 60 * 60 * 1000 ; public static final int INT_ZERO = 0; public static final int INT_ONE = 1; public static final int INT_TWO = 2; public static final int INT_THREE = 3; public static final int INT_FOUR = 4; public static final int INT_FIVE = 5; public static final int INT_SIX = 6; public static final int INT_SEVEN = 7; public static final int INT_EIGHT = 8; public static final int INT_NINE = 3; public static final int INT_TEN = 10; public static final int INT_13 = 13; public static final int INT_9999 = 9999; public static final int INT_14 = 14; public static final int INT_23 = 23; public static final int INT_59 = 59; public static final String STRING_DATE_FORMAT_YYYYMMDD = “yyyyMMdd”; public static final String STRING_DATE_FORMAT = “yyyy/MM/dd”; public static final String STRING_EMPTY = “”; public static final String STRING_SPACE = ” “; public static final String STRING_ZERO = “0″; public static final String STRING_SLASH = “/”; public static final String STRING_HYPEN= “-”; public static final String STRING_DOT = “.”; public static final char CHAR_SLASH = ‘/’; public static final char CHAR_COLON = ‘:’; public static final String STRING_COLON = “:”; public static final String FIRST_DAY = “01″ ;
/** * Getting Current Date * @return yyyyMMdd Format Date */ public static String getCurrentDate(){ return getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(new Date()); } /** * Getting Previous Day Date * @return yyyyMMdd Format Date */ public static String getPreviousDate(){ return getDate(getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(new Date().getTime()-TIME_IN_MILLI_SECONDS)); } /** * Getting Current Day * @return dd Format Day */ public static String getCurrentDateDD() { return getDateFormat(”dd”).format(new Date()); } /** * Getting Current Day Name * @return Day Name */ public static String getCurrentDay() { return getDateFormat(”EEEE”).format(new Date()); } /** * Getting Current Date * @return yyyy/MM/dd Format Date */ public static String getCurrentDateFormat() { return getDateFormat(STRING_DATE_FORMAT).format(new Date()); } /** * Getting Current Year and Month * @return yyyy/MM Format Date */ public static String getCurrentDateYM() { return getDateFormat(”yyyy/MM”).format(new Date()); } /** * Getting Current Month * @return MM */ public static String getCurrentMonth() { return getDateFormat(”MM”).format(new Date()); } /** * Getting Current Year * @return yyyy */ public static String getCurrentYear() { return getDateFormat(”yyyy”).format(new Date()); }
/** * Getting Current Time * @return HHmmssSSS Format Time */ public static String getCurrentTime() { return getDateFormat(”HHmmssSSS”).format(new Date()); }
/** * Getting Current Time * @return HHmmss Format Time */ public static String getCurrentTimeHMS() { return getDateFormat(”HHmmss”).format(new Date()); }
/** * Getting Current Time * @return HHmm Format Time */ public static String getCurrentTimeHM() { return getDateFormat(”HHmm”).format(new Date()); } /** * Getting Current Time Stamp * @return Time Stamp */ public static String getCurrentTimeStamp() { return (new Timestamp(System.currentTimeMillis())).toString(); }
/** * Get Date in YYYYMMDD Format * @param date * @param pattern * @return Date */ public static String getYMD(String date, String pattern) { try { Date d = getDateFormat(pattern).parse(date); return getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(d); } catch(ParseException e) { return date; } }
/** * Get Year and Month in YYYYMM Format * @param date * @param pattern * @return YM */ public static String getYM(String date, String pattern) { try { Date d = getDateFormat(pattern).parse(date); return getDateFormat(”yyyyMM”).format(d); } catch(ParseException e) { return date; } } /** * Setting Pattern For Date * @param pattern * @return Date Format */ private static SimpleDateFormat getDateFormat(String pattern) { SimpleDateFormat sf = new SimpleDateFormat(pattern); sf.setLenient(false); return sf; }
/** * To get the date from user and * remove the special char * @param String yyyymmdd * @return String yyyymmdd */ public static String isDateYear(String yyyymmdd) { if(yyyymmdd.contains(STRING_SLASH)){ String[] splitDate = yyyymmdd.split(STRING_SLASH); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; String strDate = splitDate[INT_TWO]; if(strMonth.length() == 1){ strMonth = STRING_ZERO + strMonth; } if(strDate.length() == 1){ strDate = STRING_ZERO + strDate; } yyyymmdd = strYear + STRING_SLASH + strMonth + STRING_SLASH + strDate; }
// To change correct format yyyymmdd = yyyymmdd.replace(STRING_SLASH, STRING_EMPTY); yyyymmdd = yyyymmdd.replace(STRING_HYPEN, STRING_EMPTY); yyyymmdd = yyyymmdd.replace(STRING_DOT, STRING_EMPTY); return yyyymmdd; } /** * To get the date from user and * remove the special char * @param String yyyymm * @return String yyyymm */ public static String isYM(String yyyymm) { if(yyyymm.contains(STRING_SLASH)){ String[] splitDate = yyyymm.split(STRING_SLASH); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; if(strMonth.length() == 1){ strMonth = STRING_ZERO + strMonth; } yyyymm = strYear + STRING_SLASH + strMonth; }
// To change correct format yyyymm = yyyymm.replace(STRING_SLASH, STRING_EMPTY); yyyymm = yyyymm.replace(STRING_HYPEN, STRING_EMPTY); yyyymm = yyyymm.replace(STRING_DOT, STRING_EMPTY); return yyyymm; } /** * To get the time from user and * remove the special char * @param String strTime * @return String strTime */ public static String isTimeHM(String strTime) {
// To change correct format strTime = strTime.replace(STRING_SLASH, STRING_EMPTY); strTime = strTime.replace(STRING_HYPEN, STRING_EMPTY); strTime = strTime.replace(STRING_DOT, STRING_EMPTY); strTime = strTime.replace(STRING_COLON, STRING_EMPTY); return strTime; }
/** * To get the date from the user and * check the date is valid or not * @param date String * @return boolean returnBoolean */ public static boolean isDateYYYYMMDD(String strDate) { boolean returnBoolean = true; if(strDate.length() > 10){ returnBoolean = false; }else if(strDate.length() < { returnBoolean = false; }else if(!strDate.contains(STRING_SLASH)){ returnBoolean = false; }else if(strDate.contains(STRING_SLASH)){ String strTempDate = strDate.replaceAll(STRING_SLASH, STRING_EMPTY); if(!isNumber(strTempDate)){ returnBoolean = false; }else if(!isValidDate(strDate)){ returnBoolean = false; } }else{ if(strDate.length() == INT_EIGHT){ String strTempDate = strDate.substring(INT_ZERO, INT_FOUR) + STRING_SLASH + strDate.substring(INT_FOUR, INT_SIX) + STRING_SLASH + strDate.substring(INT_SIX, INT_EIGHT);
if(strDate.contains(STRING_SLASH)) { returnBoolean = false; }else if(!isNumber(strDate)){ returnBoolean = false; }else if(!isValidDate(strTempDate)){ returnBoolean = false; } }else{ returnBoolean = false; } } return returnBoolean; } /** * To get the date from the user and * check the date is valid or not * @param date String * @return boolean returnBoolean */ public static boolean isDateYYYYMM(String strDate) { boolean returnBoolean = true; if(strDate.contains(STRING_SLASH)){ String strTempDate = strDate.replaceAll(STRING_SLASH, STRING_EMPTY); if(!isNumber(strTempDate)){ returnBoolean = false; }else if(!isValidYM(strDate)){ returnBoolean = false; } }else{ if(strDate.length() == INT_SIX) { String strTempDate = strDate.substring(INT_ZERO, INT_FOUR) + STRING_SLASH + strDate.substring(INT_FOUR, INT_SIX); if(strDate.contains(STRING_SLASH)) { returnBoolean = false; }else if(!isNumber(strDate)){ returnBoolean = false; }else if(!isValidYM(strTempDate)){ returnBoolean = false; } }else{ returnBoolean = false; } } return returnBoolean; }
/** * To get the Time from the user and * check the Time is valid or not * @param Time String * @return boolean returnBoolean */ public static boolean isTimeHHMM(String strTime) { boolean returnBoolean = true; if (strTime.length() == INT_FIVE) { String strTempTime = strTime.substring(INT_ZERO, INT_TWO) + strTime.substring(INT_THREE, INT_FOUR); if(!(strTime.charAt(INT_TWO) == CHAR_COLON)) { returnBoolean = false; } else if(!isNumber(strTempTime)){ returnBoolean = false; }else if(!isValidTimeHM(strTime)){ returnBoolean = false; } } else if(strTime.length() == INT_FOUR) { String strTempTime = strTime.substring(INT_ZERO, INT_TWO) + STRING_COLON + strTime.substring(INT_TWO, INT_FOUR); if(strTime.contains(STRING_COLON)) { returnBoolean = false; }else if(!isNumber(strTime)){ returnBoolean = false; }else if(!isValidTimeHM(strTempTime)){ returnBoolean = false; } }else{ returnBoolean = false; } return returnBoolean; }
/** * Removing Date Seperator From Date * @param strValue * @return date in YYYYMMDD Format */ public static String setDate(String strValue) { if(isDateYYYYMMDD(strValue)){ strValue = isDateYear(strValue); } return strValue; }
/** * Adding Date Seperator To Date * @param strValue * @return date in YYYY/MM/DD Format */ public static String getDate(String strValue){ if(strValue != null && strValue.length()== INT_EIGHT){ strValue = strValue.substring(INT_ZERO, INT_FOUR) + STRING_SLASH +strValue.substring(INT_FOUR, INT_SIX) + STRING_SLASH +strValue.substring(INT_SIX, INT_EIGHT); } return strValue; } /** * Removing Seperator From Year&Month * @param strValue * @return Year&Month in YYYYMM Format */ public static String setYM(String strValue) { if(isDateYYYYMM(strValue)){ strValue = isYM(strValue); } return strValue; }
/** * Adding Seperator From Year&Month * @param strValue * @return Year&Month in YYYY/MM Format */ public static String getYM(String strValue){ if(strValue != null && strValue.length()== INT_SIX){ strValue = strValue.substring(INT_ZERO, INT_FOUR) + STRING_SLASH +strValue.substring(INT_FOUR, INT_SIX); } return strValue; } /** * Removing Seperator From Time * @param strValue * @return Time in HHMM Format */ public static String setTime(String strValue) { if(isTimeHHMM(strValue)){ strValue = isTimeHM(strValue); } return strValue; } /** * Adding Seperator From Time * @param strValue * @return Time in HH:MM Format */ public static String getTime(String strValue){ if(strValue != null && strValue.length()== INT_FOUR){ strValue = strValue.substring(INT_ZERO, INT_TWO) + STRING_COLON + strValue.substring(INT_TWO, INT_FOUR); }else if(strValue != null && strValue.length()> INT_FOUR){ strValue = strValue.substring(INT_ZERO, INT_TWO) + STRING_COLON + strValue.substring(INT_TWO, INT_FOUR); } return strValue; } /** * Check Input is Number or not * @param strInput * @return true/false */ public static boolean isNumber(String strInput){ if(strInput==null ||strInput.equals(STRING_EMPTY)){ return false; } else{ for(int intIndex = INT_ZERO; intIndex < strInput.length(); intIndex++){ if ( !Character.isDigit(strInput.charAt(intIndex))){ return false; } } return true; } } /** * Check Input is Decimal or not * @param strInput * @return true/false */ public static boolean isDecimal(String strInput){ boolean booReturn = false; if(strInput.contains(”.”) && (strInput.indexOf(”.”) == strInput.lastIndexOf(”.”)) && (isNumber(strInput.replace(”.”, “”)))){ booReturn = true; } else if(!strInput.contains(”.”) && (isNumber(strInput))){ booReturn = true; } return booReturn; } /** * Check given String is date or not * @param strDate * @return true/false */ public static boolean isValidDate(String strDate) { try{ Date date = new Date(strDate); String[] splitDate = strDate.split(STRING_SLASH); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; String strDay = splitDate[INT_TWO]; if(strYear == null || strYear.equals(STRING_EMPTY)){ return false; }else if(strYear.length() != 4){ return false; }else if(strMonth == null || strMonth.equals(STRING_EMPTY)){ return false; }else if(strMonth.length() != 1 && strMonth.length() != 2){ return false; }else if(strDay == null || strDay.equals(STRING_EMPTY)){ return false; }else if(strDay.length() != 1 && strDay.length() != 2){ return false; } int intYear = Integer.parseInt(splitDate[INT_ZERO]); int intMonth = Integer.parseInt(splitDate[INT_ONE]) - INT_ONE; int intDate = Integer.parseInt(splitDate[INT_TWO]); if(calendar.get(Calendar.DATE) != intDate){ return false; } else if(calendar.get(Calendar.MONTH) != intMonth){ return false; }else if(intYear > INT_9999 || intYear < 1000){ return false; } else if(calendar.get(Calendar.YEAR) != intYear){ return false; } }catch (Exception e) { return false; } return true; }
/** * Check given String is Year&Month or not * @param strDate * @return true/false */ public static boolean isValidYM(String strDate) { String[] splitDate = strDate.split(STRING_SLASH); if(splitDate != null && splitDate.length == 2){ try{ int intYear = Integer.parseInt(splitDate[INT_ZERO]); int intMonth = Integer.parseInt(splitDate[INT_ONE]); if(intMonth < INT_13 && intMonth > INT_ZERO && intYear < INT_9999 && intYear > INT_ZERO){ return true; } else { return false; } }catch (Exception e) { return false; } }else{ return false; }
} /** * Check given String is Time or not * @param strDate * @return true/false */ public static boolean isValidTimeHM(String strTime) { String[] splitDate = strTime.split(STRING_COLON); if(splitDate != null && splitDate.length == 2){ try{ int intHour = Integer.parseInt(splitDate[INT_ZERO]); int intMinute = Integer.parseInt(splitDate[INT_ONE]); if(intHour < INT_ZERO){ return false; } else if(intHour > INT_23){ return false; } else if(intMinute < INT_ZERO){ return false; } else if(intMinute > INT_59){ return false; } }catch (Exception e) { return false; } }else{ return false; } return true; }
/** * Checks Two Date (End Date Greater Than From Date) * @param strFromDate * @param strToDate * @return true/false * @throws ParseException */ public static boolean CompareDate(String strFromDate, String strToDate) throws ParseException { boolean booFlag = true; if(isDateYYYYMMDD(strFromDate) && isDateYYYYMMDD(strToDate)) { if(!strFromDate.equals(strToDate)) { Date FromDate = getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).parse(setDate(strFromDate)); Date ToDate = getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).parse(setDate(strToDate)); booFlag = FromDate.before(ToDate); } } return booFlag; }
}
import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar;
public abstract class DateUtils{
public static final long TIME_IN_MILLI_SECONDS = 24 * 60 * 60 * 1000 ; public static final int INT_ZERO = 0; public static final int INT_ONE = 1; public static final int INT_TWO = 2; public static final int INT_THREE = 3; public static final int INT_FOUR = 4; public static final int INT_FIVE = 5; public static final int INT_SIX = 6; public static final int INT_SEVEN = 7; public static final int INT_EIGHT = 8; public static final int INT_NINE = 3; public static final int INT_TEN = 10; public static final int INT_13 = 13; public static final int INT_9999 = 9999; public static final int INT_14 = 14; public static final int INT_23 = 23; public static final int INT_59 = 59; public static final String STRING_DATE_FORMAT_YYYYMMDD = “yyyyMMdd”; public static final String STRING_DATE_FORMAT = “yyyy/MM/dd”; public static final String STRING_EMPTY = “”; public static final String STRING_SPACE = ” “; public static final String STRING_ZERO = “0″; public static final String STRING_SLASH = “/”; public static final String STRING_HYPEN= “-”; public static final String STRING_DOT = “.”; public static final char CHAR_SLASH = ‘/’; public static final char CHAR_COLON = ‘:’; public static final String STRING_COLON = “:”; public static final String FIRST_DAY = “01″ ; /** * Getting Current Date * @return yyyyMMdd Format Date */ public static String getCurrentDate(){ return getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(new Date()); } /** * Getting Previous Day Date * @return yyyyMMdd Format Date */ public static String getPreviousDate(){ return getDate(getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(new Date().getTime()-TIME_IN_MILLI_SECONDS)); } /** * Getting Current Day * @return dd Format Day */ public static String getCurrentDateDD() { return getDateFormat(”dd”).format(new Date()); } /** * Getting Current Day Name * @return Day Name */ public static String getCurrentDay() { return getDateFormat(”EEEE”).format(new Date()); } /** * Getting Current Date * @return yyyy/MM/dd Format Date */ public static String getCurrentDateFormat() { return getDateFormat(STRING_DATE_FORMAT).format(new Date()); } /** * Getting Current Year and Month * @return yyyy/MM Format Date */ public static String getCurrentDateYM() { return getDateFormat(”yyyy/MM”).format(new Date()); } /** * Getting Current Month * @return MM */ public static String getCurrentMonth() { return getDateFormat(”MM”).format(new Date()); } /** * Getting Current Year * @return yyyy */ public static String getCurrentYear() { return getDateFormat(”yyyy”).format(new Date()); }
/** * Getting Current Time * @return HHmmssSSS Format Time */ public static String getCurrentTime() { return getDateFormat(”HHmmssSSS”).format(new Date()); }
/** * Getting Current Time * @return HHmmss Format Time */ public static String getCurrentTimeHMS() { return getDateFormat(”HHmmss”).format(new Date()); }
/** * Getting Current Time * @return HHmm Format Time */ public static String getCurrentTimeHM() { return getDateFormat(”HHmm”).format(new Date()); } /** * Getting Current Time Stamp * @return Time Stamp */ public static String getCurrentTimeStamp() { return (new Timestamp(System.currentTimeMillis())).toString(); }
/** * Get Date in YYYYMMDD Format * @param date * @param pattern * @return Date */ public static String getYMD(String date, String pattern) { try { Date d = getDateFormat(pattern).parse(date); return getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(d); } catch(ParseException e) { return date; } }
/** * Get Year and Month in YYYYMM Format * @param date * @param pattern * @return YM */ public static String getYM(String date, String pattern) { try { Date d = getDateFormat(pattern).parse(date); return getDateFormat(”yyyyMM”).format(d); } catch(ParseException e) { return date; } } /** * Setting Pattern For Date * @param pattern * @return Date Format */ private static SimpleDateFormat getDateFormat(String pattern) { SimpleDateFormat sf = new SimpleDateFormat(pattern); sf.setLenient(false); return sf; }
/** * To get the date from user and * remove the special char * @param String yyyymmdd * @return String yyyymmdd */ public static String isDateYear(String yyyymmdd) { if(yyyymmdd.contains(STRING_SLASH)){ String[] splitDate = yyyymmdd.split(STRING_SLASH); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; String strDate = splitDate[INT_TWO]; if(strMonth.length() == 1){ strMonth = STRING_ZERO + strMonth; } if(strDate.length() == 1){ strDate = STRING_ZERO + strDate; } yyyymmdd = strYear + STRING_SLASH + strMonth + STRING_SLASH + strDate; }
// To change correct format yyyymmdd = yyyymmdd.replace(STRING_SLASH, STRING_EMPTY); yyyymmdd = yyyymmdd.replace(STRING_HYPEN, STRING_EMPTY); yyyymmdd = yyyymmdd.replace(STRING_DOT, STRING_EMPTY); return yyyymmdd; } /** * To get the date from user and * remove the special char * @param String yyyymm * @return String yyyymm */ public static String isYM(String yyyymm) { if(yyyymm.contains(STRING_SLASH)){ String[] splitDate = yyyymm.split(STRING_SLASH); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; if(strMonth.length() == 1){ strMonth = STRING_ZERO + strMonth; } yyyymm = strYear + STRING_SLASH + strMonth; }
// To change correct format yyyymm = yyyymm.replace(STRING_SLASH, STRING_EMPTY); yyyymm = yyyymm.replace(STRING_HYPEN, STRING_EMPTY); yyyymm = yyyymm.replace(STRING_DOT, STRING_EMPTY); return yyyymm; } /** * To get the time from user and * remove the special char * @param String strTime * @return String strTime */ public static String isTimeHM(String strTime) {
// To change correct format strTime = strTime.replace(STRING_SLASH, STRING_EMPTY); strTime = strTime.replace(STRING_HYPEN, STRING_EMPTY); strTime = strTime.replace(STRING_DOT, STRING_EMPTY); strTime = strTime.replace(STRING_COLON, STRING_EMPTY); return strTime; }
/** * To get the date from the user and * check the date is valid or not * @param date String * @return boolean returnBoolean */ public static boolean isDateYYYYMMDD(String strDate) { boolean returnBoolean = true; if(strDate.length() > 10){ returnBoolean = false; }else if(strDate.length() < { returnBoolean = false; }else if(!strDate.contains(STRING_SLASH)){ returnBoolean = false; }else if(strDate.contains(STRING_SLASH)){ String strTempDate = strDate.replaceAll(STRING_SLASH, STRING_EMPTY); if(!isNumber(strTempDate)){ returnBoolean = false; }else if(!isValidDate(strDate)){ returnBoolean = false; } }else{ if(strDate.length() == INT_EIGHT){ String strTempDate = strDate.substring(INT_ZERO, INT_FOUR) + STRING_SLASH + strDate.substring(INT_FOUR, INT_SIX) + STRING_SLASH + strDate.substring(INT_SIX, INT_EIGHT);
if(strDate.contains(STRING_SLASH)) { returnBoolean = false; }else if(!isNumber(strDate)){ returnBoolean = false; }else if(!isValidDate(strTempDate)){ returnBoolean = false; } }else{ returnBoolean = false; } } return returnBoolean; } /** * To get the date from the user and * check the date is valid or not * @param date String * @return boolean returnBoolean */ public static boolean isDateYYYYMM(String strDate) { boolean returnBoolean = true; if(strDate.contains(STRING_SLASH)){ String strTempDate = strDate.replaceAll(STRING_SLASH, STRING_EMPTY); if(!isNumber(strTempDate)){ returnBoolean = false; }else if(!isValidYM(strDate)){ returnBoolean = false; } }else{ if(strDate.length() == INT_SIX) { String strTempDate = strDate.substring(INT_ZERO, INT_FOUR) + STRING_SLASH + strDate.substring(INT_FOUR, INT_SIX); if(strDate.contains(STRING_SLASH)) { returnBoolean = false; }else if(!isNumber(strDate)){ returnBoolean = false; }else if(!isValidYM(strTempDate)){ returnBoolean = false; } }else{ returnBoolean = false; } } return returnBoolean; }
/** * To get the Time from the user and * check the Time is valid or not * @param Time String * @return boolean returnBoolean */ public static boolean isTimeHHMM(String strTime) { boolean returnBoolean = true; if (strTime.length() == INT_FIVE) { String strTempTime = strTime.substring(INT_ZERO, INT_TWO) + strTime.substring(INT_THREE, INT_FOUR); if(!(strTime.charAt(INT_TWO) == CHAR_COLON)) { returnBoolean = false; } else if(!isNumber(strTempTime)){ returnBoolean = false; }else if(!isValidTimeHM(strTime)){ returnBoolean = false; } } else if(strTime.length() == INT_FOUR) { String strTempTime = strTime.substring(INT_ZERO, INT_TWO) + STRING_COLON + strTime.substring(INT_TWO, INT_FOUR); if(strTime.contains(STRING_COLON)) { returnBoolean = false; }else if(!isNumber(strTime)){ returnBoolean = false; }else if(!isValidTimeHM(strTempTime)){ returnBoolean = false; } }else{ returnBoolean = false; } return returnBoolean; }
/** * Removing Date Seperator From Date * @param strValue * @return date in YYYYMMDD Format */ public static String setDate(String strValue) { if(isDateYYYYMMDD(strValue)){ strValue = isDateYear(strValue); } return strValue; }
/** * Adding Date Seperator To Date * @param strValue * @return date in YYYY/MM/DD Format */ public static String getDate(String strValue){ if(strValue != null && strValue.length()== INT_EIGHT){ strValue = strValue.substring(INT_ZERO, INT_FOUR) + STRING_SLASH +strValue.substring(INT_FOUR, INT_SIX) + STRING_SLASH +strValue.substring(INT_SIX, INT_EIGHT); } return strValue; } /** * Removing Seperator From Year&Month * @param strValue * @return Year&Month in YYYYMM Format */ public static String setYM(String strValue) { if(isDateYYYYMM(strValue)){ strValue = isYM(strValue); } return strValue; }
/** * Adding Seperator From Year&Month * @param strValue * @return Year&Month in YYYY/MM Format */ public static String getYM(String strValue){ if(strValue != null && strValue.length()== INT_SIX){ strValue = strValue.substring(INT_ZERO, INT_FOUR) + STRING_SLASH +strValue.substring(INT_FOUR, INT_SIX); } return strValue; } /** * Removing Seperator From Time * @param strValue * @return Time in HHMM Format */ public static String setTime(String strValue) { if(isTimeHHMM(strValue)){ strValue = isTimeHM(strValue); } return strValue; } /** * Adding Seperator From Time * @param strValue * @return Time in HH:MM Format */ public static String getTime(String strValue){ if(strValue != null && strValue.length()== INT_FOUR){ strValue = strValue.substring(INT_ZERO, INT_TWO) + STRING_COLON + strValue.substring(INT_TWO, INT_FOUR); }else if(strValue != null && strValue.length()> INT_FOUR){ strValue = strValue.substring(INT_ZERO, INT_TWO) + STRING_COLON + strValue.substring(INT_TWO, INT_FOUR); } return strValue; } /** * Check Input is Number or not * @param strInput * @return true/false */ public static boolean isNumber(String strInput){ if(strInput==null ||strInput.equals(STRING_EMPTY)){ return false; } else{ for(int intIndex = INT_ZERO; intIndex < strInput.length(); intIndex++){ if ( !Character.isDigit(strInput.charAt(intIndex))){ return false; } } return true; } } /** * Check Input is Decimal or not * @param strInput * @return true/false */ public static boolean isDecimal(String strInput){ boolean booReturn = false; if(strInput.contains(”.”) && (strInput.indexOf(”.”) == strInput.lastIndexOf(”.”)) && (isNumber(strInput.replace(”.”, “”)))){ booReturn = true; } else if(!strInput.contains(”.”) && (isNumber(strInput))){ booReturn = true; } return booReturn; } /** * Check given String is date or not * @param strDate * @return true/false */ public static boolean isValidDate(String strDate) { try{ Date date = new Date(strDate); String[] splitDate = strDate.split(STRING_SLASH); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; String strDay = splitDate[INT_TWO]; if(strYear == null || strYear.equals(STRING_EMPTY)){ return false; }else if(strYear.length() != 4){ return false; }else if(strMonth == null || strMonth.equals(STRING_EMPTY)){ return false; }else if(strMonth.length() != 1 && strMonth.length() != 2){ return false; }else if(strDay == null || strDay.equals(STRING_EMPTY)){ return false; }else if(strDay.length() != 1 && strDay.length() != 2){ return false; } int intYear = Integer.parseInt(splitDate[INT_ZERO]); int intMonth = Integer.parseInt(splitDate[INT_ONE]) - INT_ONE; int intDate = Integer.parseInt(splitDate[INT_TWO]); if(calendar.get(Calendar.DATE) != intDate){ return false; } else if(calendar.get(Calendar.MONTH) != intMonth){ return false; }else if(intYear > INT_9999 || intYear < 1000){ return false; } else if(calendar.get(Calendar.YEAR) != intYear){ return false; } }catch (Exception e) { return false; } return true; }
/** * Check given String is Year&Month or not * @param strDate * @return true/false */ public static boolean isValidYM(String strDate) { String[] splitDate = strDate.split(STRING_SLASH); if(splitDate != null && splitDate.length == 2){ try{ int intYear = Integer.parseInt(splitDate[INT_ZERO]); int intMonth = Integer.parseInt(splitDate[INT_ONE]); if(intMonth < INT_13 && intMonth > INT_ZERO && intYear < INT_9999 && intYear > INT_ZERO){ return true; } else { return false; } }catch (Exception e) { return false; } }else{ return false; }
} /** * Check given String is Time or not * @param strDate * @return true/false */ public static boolean isValidTimeHM(String strTime) { String[] splitDate = strTime.split(STRING_COLON); if(splitDate != null && splitDate.length == 2){ try{ int intHour = Integer.parseInt(splitDate[INT_ZERO]); int intMinute = Integer.parseInt(splitDate[INT_ONE]); if(intHour < INT_ZERO){ return false; } else if(intHour > INT_23){ return false; } else if(intMinute < INT_ZERO){ return false; } else if(intMinute > INT_59){ return false; } }catch (Exception e) { return false; } }else{ return false; } return true; }
/** * Checks Two Date (End Date Greater Than From Date) * @param strFromDate * @param strToDate * @return true/false * @throws ParseException */ public static boolean CompareDate(String strFromDate, String strToDate) throws ParseException { boolean booFlag = true; if(isDateYYYYMMDD(strFromDate) && isDateYYYYMMDD(strToDate)) { if(!strFromDate.equals(strToDate)) { Date FromDate = getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).parse(setDate(strFromDate)); Date ToDate = getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).parse(setDate(strToDate)); booFlag = FromDate.before(ToDate); } } return booFlag; }
}
import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar;
public abstract class DateUtils{
public static final long TIME_IN_MILLI_SECONDS = 24 * 60 * 60 * 1000 ; public static final int INT_ZERO = 0; public static final int INT_ONE = 1; public static final int INT_TWO = 2; public static final int INT_THREE = 3; public static final int INT_FOUR = 4; public static final int INT_FIVE = 5; public static final int INT_SIX = 6; public static final int INT_SEVEN = 7; public static final int INT_EIGHT = 8; public static final int INT_NINE = 3; public static final int INT_TEN = 10; public static final int INT_13 = 13; public static final int INT_9999 = 9999; public static final int INT_14 = 14; public static final int INT_23 = 23; public static final int INT_59 = 59; public static final String STRING_DATE_FORMAT_YYYYMMDD = “yyyyMMdd”; public static final String STRING_DATE_FORMAT = “yyyy/MM/dd”; public static final String STRING_EMPTY = “”; public static final String STRING_SPACE = ” “; public static final String STRING_ZERO = “0″; public static final String STRING_SLASH = “/”; public static final String STRING_HYPEN= “-”; public static final String STRING_DOT = “.”; public static final char CHAR_SLASH = ‘/’; public static final char CHAR_COLON = ‘:’; public static final String STRING_COLON = “:”; public static final String FIRST_DAY = “01″ ; /** * Getting Current Date * @return yyyyMMdd Format Date */ public static String getCurrentDate(){ return getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(new Date()); } /** * Getting Previous Day Date * @return yyyyMMdd Format Date */ public static String getPreviousDate(){ return getDate(getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(new Date().getTime()-TIME_IN_MILLI_SECONDS)); } /** * Getting Current Day * @return dd Format Day */ public static String getCurrentDateDD() { return getDateFormat(”dd”).format(new Date()); } /** * Getting Current Day Name * @return Day Name */ public static String getCurrentDay() { return getDateFormat(”EEEE”).format(new Date()); } /** * Getting Current Date * @return yyyy/MM/dd Format Date */ public static String getCurrentDateFormat() { return getDateFormat(STRING_DATE_FORMAT).format(new Date()); } /** * Getting Current Year and Month * @return yyyy/MM Format Date */ public static String getCurrentDateYM() { return getDateFormat(”yyyy/MM”).format(new Date()); } /** * Getting Current Month * @return MM */ public static String getCurrentMonth() { return getDateFormat(”MM”).format(new Date()); } /** * Getting Current Year * @return yyyy */ public static String getCurrentYear() { return getDateFormat(”yyyy”).format(new Date()); }
/** * Getting Current Time * @return HHmmssSSS Format Time */ public static String getCurrentTime() { return getDateFormat(”HHmmssSSS”).format(new Date()); }
/** * Getting Current Time * @return HHmmss Format Time */ public static String getCurrentTimeHMS() { return getDateFormat(”HHmmss”).format(new Date()); }
/** * Getting Current Time * @return HHmm Format Time */ public static String getCurrentTimeHM() { return getDateFormat(”HHmm”).format(new Date()); } /** * Getting Current Time Stamp * @return Time Stamp */ public static String getCurrentTimeStamp() { return (new Timestamp(System.currentTimeMillis())).toString(); }
/** * Get Date in YYYYMMDD Format * @param date * @param pattern * @return Date */ public static String getYMD(String date, String pattern) { try { Date d = getDateFormat(pattern).parse(date); return getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).format(d); } catch(ParseException e) { return date; } }
/** * Get Year and Month in YYYYMM Format * @param date * @param pattern * @return YM */ public static String getYM(String date, String pattern) { try { Date d = getDateFormat(pattern).parse(date); return getDateFormat(”yyyyMM”).format(d); } catch(ParseException e) { return date; } } /** * Setting Pattern For Date * @param pattern * @return Date Format */ private static SimpleDateFormat getDateFormat(String pattern) { SimpleDateFormat sf = new SimpleDateFormat(pattern); sf.setLenient(false); return sf; }
/** * To get the date from user and * remove the special char * @param String yyyymmdd * @return String yyyymmdd */ public static String isDateYear(String yyyymmdd) { if(yyyymmdd.contains(STRING_SLASH)){ String[] splitDate = yyyymmdd.split(STRING_SLASH); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; String strDate = splitDate[INT_TWO]; if(strMonth.length() == 1){ strMonth = STRING_ZERO + strMonth; } if(strDate.length() == 1){ strDate = STRING_ZERO + strDate; } yyyymmdd = strYear + STRING_SLASH + strMonth + STRING_SLASH + strDate; }
// To change correct format yyyymmdd = yyyymmdd.replace(STRING_SLASH, STRING_EMPTY); yyyymmdd = yyyymmdd.replace(STRING_HYPEN, STRING_EMPTY); yyyymmdd = yyyymmdd.replace(STRING_DOT, STRING_EMPTY); return yyyymmdd; } /** * To get the date from user and * remove the special char * @param String yyyymm * @return String yyyymm */ public static String isYM(String yyyymm) { if(yyyymm.contains(STRING_SLASH)){ String[] splitDate = yyyymm.split(STRING_SLASH); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; if(strMonth.length() == 1){ strMonth = STRING_ZERO + strMonth; } yyyymm = strYear + STRING_SLASH + strMonth; }
// To change correct format yyyymm = yyyymm.replace(STRING_SLASH, STRING_EMPTY); yyyymm = yyyymm.replace(STRING_HYPEN, STRING_EMPTY); yyyymm = yyyymm.replace(STRING_DOT, STRING_EMPTY); return yyyymm; } /** * To get the time from user and * remove the special char * @param String strTime * @return String strTime */ public static String isTimeHM(String strTime) {
// To change correct format strTime = strTime.replace(STRING_SLASH, STRING_EMPTY); strTime = strTime.replace(STRING_HYPEN, STRING_EMPTY); strTime = strTime.replace(STRING_DOT, STRING_EMPTY); strTime = strTime.replace(STRING_COLON, STRING_EMPTY); return strTime; }
/** * To get the date from the user and * check the date is valid or not * @param date String * @return boolean returnBoolean */ public static boolean isDateYYYYMMDD(String strDate) { boolean returnBoolean = true; if(strDate.length() > 10){ returnBoolean = false; }else if(strDate.length() < { returnBoolean = false; }else if(!strDate.contains(STRING_SLASH)){ returnBoolean = false; }else if(strDate.contains(STRING_SLASH)){ String strTempDate = strDate.replaceAll(STRING_SLASH, STRING_EMPTY); if(!isNumber(strTempDate)){ returnBoolean = false; }else if(!isValidDate(strDate)){ returnBoolean = false; } }else{ if(strDate.length() == INT_EIGHT){ String strTempDate = strDate.substring(INT_ZERO, INT_FOUR) + STRING_SLASH + strDate.substring(INT_FOUR, INT_SIX) + STRING_SLASH + strDate.substring(INT_SIX, INT_EIGHT);
if(strDate.contains(STRING_SLASH)) { returnBoolean = false; }else if(!isNumber(strDate)){ returnBoolean = false; }else if(!isValidDate(strTempDate)){ returnBoolean = false; } }else{ returnBoolean = false; } } return returnBoolean; } /** * To get the date from the user and * check the date is valid or not * @param date String * @return boolean returnBoolean */ public static boolean isDateYYYYMM(String strDate) { boolean returnBoolean = true; if(strDate.contains(STRING_SLASH)){ String strTempDate = strDate.replaceAll(STRING_SLASH, STRING_EMPTY); if(!isNumber(strTempDate)){ returnBoolean = false; }else if(!isValidYM(strDate)){ returnBoolean = false; } }else{ if(strDate.length() == INT_SIX) { String strTempDate = strDate.substring(INT_ZERO, INT_FOUR) + STRING_SLASH + strDate.substring(INT_FOUR, INT_SIX); if(strDate.contains(STRING_SLASH)) { returnBoolean = false; }else if(!isNumber(strDate)){ returnBoolean = false; }else if(!isValidYM(strTempDate)){ returnBoolean = false; } }else{ returnBoolean = false; } } return returnBoolean; }
/** * To get the Time from the user and * check the Time is valid or not * @param Time String * @return boolean returnBoolean */ public static boolean isTimeHHMM(String strTime) { boolean returnBoolean = true; if (strTime.length() == INT_FIVE) { String strTempTime = strTime.substring(INT_ZERO, INT_TWO) + strTime.substring(INT_THREE, INT_FOUR); if(!(strTime.charAt(INT_TWO) == CHAR_COLON)) { returnBoolean = false; } else if(!isNumber(strTempTime)){ returnBoolean = false; }else if(!isValidTimeHM(strTime)){ returnBoolean = false; } } else if(strTime.length() == INT_FOUR) { String strTempTime = strTime.substring(INT_ZERO, INT_TWO) + STRING_COLON + strTime.substring(INT_TWO, INT_FOUR); if(strTime.contains(STRING_COLON)) { returnBoolean = false; }else if(!isNumber(strTime)){ returnBoolean = false; }else if(!isValidTimeHM(strTempTime)){ returnBoolean = false; } }else{ returnBoolean = false; } return returnBoolean; }
/** * Removing Date Seperator From Date * @param strValue * @return date in YYYYMMDD Format */ public static String setDate(String strValue) { if(isDateYYYYMMDD(strValue)){ strValue = isDateYear(strValue); } return strValue; }
/** * Adding Date Seperator To Date * @param strValue * @return date in YYYY/MM/DD Format */ public static String getDate(String strValue){ if(strValue != null && strValue.length()== INT_EIGHT){ strValue = strValue.substring(INT_ZERO, INT_FOUR) + STRING_SLASH +strValue.substring(INT_FOUR, INT_SIX) + STRING_SLASH +strValue.substring(INT_SIX, INT_EIGHT); } return strValue; } /** * Removing Seperator From Year&Month * @param strValue * @return Year&Month in YYYYMM Format */ public static String setYM(String strValue) { if(isDateYYYYMM(strValue)){ strValue = isYM(strValue); } return strValue; }
/** * Adding Seperator From Year&Month * @param strValue * @return Year&Month in YYYY/MM Format */ public static String getYM(String strValue){ if(strValue != null && strValue.length()== INT_SIX){ strValue = strValue.substring(INT_ZERO, INT_FOUR) + STRING_SLASH +strValue.substring(INT_FOUR, INT_SIX); } return strValue; } /** * Removing Seperator From Time * @param strValue * @return Time in HHMM Format */ public static String setTime(String strValue) { if(isTimeHHMM(strValue)){ strValue = isTimeHM(strValue); } return strValue; } /** * Adding Seperator From Time * @param strValue * @return Time in HH:MM Format */ public static String getTime(String strValue){ if(strValue != null && strValue.length()== INT_FOUR){ strValue = strValue.substring(INT_ZERO, INT_TWO) + STRING_COLON + strValue.substring(INT_TWO, INT_FOUR); }else if(strValue != null && strValue.length()> INT_FOUR){ strValue = strValue.substring(INT_ZERO, INT_TWO) + STRING_COLON + strValue.substring(INT_TWO, INT_FOUR); } return strValue; } /** * Check Input is Number or not * @param strInput * @return true/false */ public static boolean isNumber(String strInput){ if(strInput==null ||strInput.equals(STRING_EMPTY)){ return false; } else{ for(int intIndex = INT_ZERO; intIndex < strInput.length(); intIndex++){ if ( !Character.isDigit(strInput.charAt(intIndex))){ return false; } } return true; } } /** * Check Input is Decimal or not * @param strInput * @return true/false */ public static boolean isDecimal(String strInput){ boolean booReturn = false; if(strInput.contains(”.”) && (strInput.indexOf(”.”) == strInput.lastIndexOf(”.”)) && (isNumber(strInput.replace(”.”, “”)))){ booReturn = true; } else if(!strInput.contains(”.”) && (isNumber(strInput))){ booReturn = true; } return booReturn; } /** * Check given String is date or not * @param strDate * @return true/false */ public static boolean isValidDate(String strDate) { try{ Date date = new Date(strDate); String[] splitDate = strDate.split(STRING_SLASH); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); String strYear = splitDate[INT_ZERO]; String strMonth = splitDate[INT_ONE]; String strDay = splitDate[INT_TWO]; if(strYear == null || strYear.equals(STRING_EMPTY)){ return false; }else if(strYear.length() != 4){ return false; }else if(strMonth == null || strMonth.equals(STRING_EMPTY)){ return false; }else if(strMonth.length() != 1 && strMonth.length() != 2){ return false; }else if(strDay == null || strDay.equals(STRING_EMPTY)){ return false; }else if(strDay.length() != 1 && strDay.length() != 2){ return false; } int intYear = Integer.parseInt(splitDate[INT_ZERO]); int intMonth = Integer.parseInt(splitDate[INT_ONE]) - INT_ONE; int intDate = Integer.parseInt(splitDate[INT_TWO]); if(calendar.get(Calendar.DATE) != intDate){ return false; } else if(calendar.get(Calendar.MONTH) != intMonth){ return false; }else if(intYear > INT_9999 || intYear < 1000){ return false; } else if(calendar.get(Calendar.YEAR) != intYear){ return false; } }catch (Exception e) { return false; } return true; }
/** * Check given String is Year&Month or not * @param strDate * @return true/false */ public static boolean isValidYM(String strDate) { String[] splitDate = strDate.split(STRING_SLASH); if(splitDate != null && splitDate.length == 2){ try{ int intYear = Integer.parseInt(splitDate[INT_ZERO]); int intMonth = Integer.parseInt(splitDate[INT_ONE]); if(intMonth < INT_13 && intMonth > INT_ZERO && intYear < INT_9999 && intYear > INT_ZERO){ return true; } else { return false; } }catch (Exception e) { return false; } }else{ return false; }
} /** * Check given String is Time or not * @param strDate * @return true/false */ public static boolean isValidTimeHM(String strTime) { String[] splitDate = strTime.split(STRING_COLON); if(splitDate != null && splitDate.length == 2){ try{ int intHour = Integer.parseInt(splitDate[INT_ZERO]); int intMinute = Integer.parseInt(splitDate[INT_ONE]); if(intHour < INT_ZERO){ return false; } else if(intHour > INT_23){ return false; } else if(intMinute < INT_ZERO){ return false; } else if(intMinute > INT_59){ return false; } }catch (Exception e) { return false; } }else{ return false; } return true; }
/** * Checks Two Date (End Date Greater Than From Date) * @param strFromDate * @param strToDate * @return true/false * @throws ParseException */ public static boolean CompareDate(String strFromDate, String strToDate) throws ParseException { boolean booFlag = true; if(isDateYYYYMMDD(strFromDate) && isDateYYYYMMDD(strToDate)) { if(!strFromDate.equals(strToDate)) { Date FromDate = getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).parse(setDate(strFromDate)); Date ToDate = getDateFormat(STRING_DATE_FORMAT_YYYYMMDD).parse(setDate(strToDate)); booFlag = FromDate.before(ToDate); } } return booFlag; }
}
OK, Now leave me the comments or sugesstion in my comment box.
Thanking you for using my Codes
|