RegEx to validate date between 1900 & today
Hi,
I have a RegEx which validates the date of birth
(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)dd
But I want it to validate date of birth until today only from 1900
How can I do that using regular expression?
a®s
Edited by: a®s on Jul 2, 2008 3:00 PM
Thanks for your reply Jan.
Jan Stallkamp wrote:
> In general regex tend to be easy to write but hard to read. So from a maintance perspective they might not be the best choice. >
I accept the fact that you mentioned above.
I am planning different RegEx for different date formats.
This application need to be called from a PHP page. so don't find any other way to tackle this issue.
Any other info?
a®
Similar Messages
-
How to validate date between Header and Detail Block..
Hi All,
I was trying to find a way where, suppose I enter 'from date' and 'to date' in the header block.then in detail block all 'from dates' and 'to dates' should be restricted between the dates entered in the header block.
Thank youOr U Can Simply set in the child item lowest / highest Allowed Value
Invoke Property pallete for child date item and set the following
lowest Allowed Value :header.from_date (must be prefix with :)
Highest Allowed Value :header.to_date
siju.koiply -
How to validate date formate YYYY-MM-DDThh:mm:ss ?
i have implemented validation for YYYY-MM-DD <br>
but how to validate for time <br>
here is the code for date validation
could you please anyone help me on this issue
<br><br><br> public static boolean validateDateFormate(String date) <br><br>
{ <br>
<br> try { <br>
<br> String dateFormat="yyyy-MM-ddYYYY-MM-DDThh:mm:ss";
<br> String temp = date.substring(0,date.indexOf("-"));
<br> if(temp.length()!= 4)
<br> return false;
<br> SimpleDateFormat df=new SimpleDateFormat(dateFormat);
<br> Date date1=df.parse(date);
<br>String resultDateString=df.format(date1);
<br>System.out.println("date1"+resultDateString);
<br> if ( !date.equals(resultDateString)) { return false; }
<br> } catch (Exception de) {
<br> System.out.println(de);
<br> return false;
<br>
<br>}
<br> return true;
<br> }A useful Data util class
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.StringTokenizer;
public final class SlacDate implements Comparable
public final static int FormatDDMMCCYY = 0;
public final static int FormatMMDDCCYY = 1;
public final static int FormatDATETIME = 2;
public final static int FormatMMMDDTIME = 3;
public final static int FormatTIMESTAMP = 4;
public final static int FormatCCYYMMDD = 5;
public final static int FormatCCYYMMDDHHMM = 6;
public final static int FormatCCYYMMDDHHMMSS = 7;
public final static int FormatDDMMCCYYTIME = 8;
public final static int FormatDATEVERBOSE = 9;
public final static int FormatDATETIMEVERBOSE = 10;
public final static int FormatHHMMSS = 11;
public final static int FormatHHMMSSMIL = 12;
public final static int FormatDB2TIMESTAMP = 13;
public final static int FormatUDBTIMESTAMP = 14;
public final static int JANUARY = 1;
public final static int FEBRUARY = 2;
public final static int MARCH = 3;
public final static int APRIL = 4;
public final static int MAY = 5;
public final static int JUNE = 6;
public final static int JULY = 7;
public final static int AUGUST = 8;
public final static int SEPTEMBER = 9;
public final static int OCTOBER = 10;
public final static int NOVEMBER = 11;
public final static int DECEMBER = 12;
public final static int MONTHS_IN_YEAR = 12;
public final static int SUNDAY = 1;
public final static int MONDAY = 2;
public final static int TUESDAY = 3;
public final static int WEDNESDAY = 4;
public final static int THURSDAY = 5;
public final static int FRIDAY = 6;
public final static int SATURDAY = 7;
public final static int DAYS_IN_WEEK = 7;
private final static int DefaultHours = 12;
private final static int DefaultMinutes = 0;
private final static int DefaultSeconds = 0;
private final static int DefaultMillis = 0;
private final static int DaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
private final static String MonthAbbrev[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
private final static String MonthVerbose[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
private final static String DaysOfWeekAbbrev[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
private final static String DaysOfWeek[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
private final static String DayExtension[] = { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" };
private final static String EMPTY = "";
private final static String COLON = ":";
private final static String PERIOD = ".";
private final static String HYPHEN = "-";
private final static String SPACE = " ";
private final static String ZERO = "0";
private static String s_dateSep = HYPHEN;
private int m_dd, m_mm, m_yyyy, m_hh, m_min, m_ss, m_mil;
private static long MillisInSecond = 1000;
private static long MillisInMinute = MillisInSecond * 60;
private static long MillisInHour = MillisInMinute * 60;
private static long MillisInDay = MillisInHour * 24;
* JDK_BST_FIX
* Static initialisation block - check JDK vendor/version in order to determine whether
* an adjustment to correctly report British summertime needs to be made. This is required
* in order to fix a bug in some Sun & IBM JDKs. If an untested version of the Sun or IBM JDK
* is used, we log an error message warning that this block of code should be examained and
* changed as appropriate. This is ugly, but will prevent a new JDK being used and this bug
* creeping back in.
* Note the following JDKs have been tested under both NT & AIX
* JDK Version NT AIX
* 1.1.7 (IBM) x x
* 1.1.7A (IBM) ?
* 1.1.7B (IBM) ? ?
* 1.1.8 (IBM) x x
* 1.2.2 (IBM) ok ok
* 1.1.7 (SUN) x x
* 1.1.8 (SUN) x x
* 1.2 (SUN) x x
private final static String SunVendorString = "Sun Microsystems Inc.";
private final static String IBMVendorString = "IBM"; // Can also be 'IBM Corporation'
private final static String SunProblemJDKs[] = { "1.1.4", "1.1.5", "1.1.6", "1.1.7", "1.1.7A", "1.1.7B", "1.1.8", "1.2", "1.2.2" };
private final static String SunOKJDKs[] = { "1.0.2", "1.1.2", "1.1.3", "1.4.0", "1.4.2"};
private final static String IBMProblemJDKs[] = { "1.1.4", "1.1.5", "1.1.6", "1.1.7", "1.1.7A", "1.1.8" };
private final static String IBMOKJDKs[] = { "1.0.2", "1.1.2", "1.1.3", "1.1.7B", "1.2.2", "1.3.0", "1.3.1" };
private static boolean s_adjustForBST = false;
static
String vendor = System.getProperty("java.vendor");
String jdk = System.getProperty("java.version");
// Check applies to Sun only.
if (vendor.equals(SunVendorString) || vendor.startsWith(IBMVendorString))
String problemJDKs[] = null;
String OKJDKs[] = null;
if (vendor.equals(SunVendorString))
problemJDKs = SunProblemJDKs;
OKJDKs = SunOKJDKs;
else
problemJDKs = IBMProblemJDKs;
OKJDKs = IBMOKJDKs;
// Determine whether we need to make adjustment
for (int i = 0; i < problemJDKs.length; i++)
if (problemJDKs.equals(jdk))
s_adjustForBST = true;
break;
// If we do not need to make the adjustment then check that the
// JDK reported is one of the versions that we know to be good.
// If it is not log an error message.
if (!s_adjustForBST)
boolean goodJDK = false;
for (int i = 0; i < OKJDKs.length; i++)
if (OKJDKs[i].equals(jdk))
goodJDK = true;
break;
/* CR176 - we now anticipate that all JDKs post 1.3.x are "good" ones
if (!goodJDK)
// We do not use the SingletonLogger mechanism since we
// cannot be sure that these singleton objects have been instantiated
// at this point, and in any case it is not desirable to introduce
// this dependancy into SlacDate.
System.err.println("JDK VERSION ERROR : Unsupported JDK - '" + jdk + "' provided by '" + vendor + "'. SlacDate class requires examination.");
* Construct the date with todays date.
* <p>This should be the only place where a Date object is explicitly instantiated. All
* other code should use SlacDate. If the s_adjustForBST flag is set and the date falls
* between the last sunday of March and the last Sunday of October (inclusive) then we need
* to make an adjustment of +1 hour so that British Summertime is correctly reported.
private SlacDate()
init(Calendar.getInstance());
* Construct the date with the specified day, month and year.
* @param year The year to set the date to
* @param month The month to set the date to
* @param date The date to set the date to
* @exception InvalidDateException Invalid date parameters passed in.
public SlacDate(int year, int month, int date) throws InvalidDateException
init(year, month, date, DefaultHours, DefaultMinutes, DefaultSeconds, DefaultMillis);
* Construct the date with the specified day, month, year, hour and minute.
* @param year The year to set the date to
* @param month The month to set the date to
* @param date The date to set the date to
* @param hr The hour to set the date to
* @param min The minute to set the date to
* @exception InvalidDateException Invalid date parameters passed in.
public SlacDate(int year, int month, int date, int hr, int min) throws InvalidDateException
init(year, month, date, hr, min, DefaultSeconds, DefaultMillis);
* Construct the date with the specified day, month, year, hour, minute and second.
* Will default to 0 milliseconds.
* @param year The year to set the date to
* @param month The month to set the date to
* @param date The date to set the date to
* @param hr The hour to set the date to
* @param min The minute to set the date to
* @param sec The second to set the date to
* @exception InvalidDateException Invalid date parameters passed in.
public SlacDate(int year, int month, int date, int hr, int min, int sec) throws InvalidDateException
init(year, month, date, hr, min, sec, DefaultMillis);
* Construct the date with the specified day, month, year, hour, minute, second and milliseconds.
* @param year The year to set the date to
* @param month The month to set the date to
* @param date The date to set the date to
* @param hr The hour to set the date to
* @param min The minute to set the date to
* @param sec The second to set the date to
* @param millis The milliseconds to set the date to
* @exception InvalidDateException Invalid date parameters passed in.
public SlacDate(int year, int month, int date, int hr, int min, int sec, int millis) throws InvalidDateException
init(year, month, date, hr, min, sec, millis);
* Construct the date from a timestamp.
public SlacDate(long timestamp) throws InvalidDateException
Calendar cal = Calendar.getInstance();
cal.setTime(new Date(timestamp));
init(cal);
* Construct the date from the specified string. Note that the date must
* be in day/month/year format.
* @param date The date string.
* @exception InvalidDateException The date passed in is invalid.
public SlacDate(String date) throws InvalidDateException
init(date);
* Construct the date from the specified string. The format passed in will
* identify the format of the date.
* @param date The date string.
* @param format The format of the date.
* @exception InvalidDateException The date passed in is invalid.
public SlacDate(String date, int format) throws InvalidDateException
if (format == FormatCCYYMMDD || format == FormatCCYYMMDDHHMM || format == FormatCCYYMMDDHHMMSS)
boolean valid = false;
date = date.trim();
if (date.length() >= 8)
try
int year = Integer.parseInt(date.substring(0,4));
int month = Integer.parseInt(date.substring(4,6));
int day = Integer.parseInt(date.substring(6,8));
int hour;
int min;
int sec;
if (date.length() > 8)
hour = Integer.parseInt(date.substring(8,10));
min = Integer.parseInt(date.substring(10,12));
if (date.length() >= 14)
sec = Integer.parseInt(date.substring(12,14));
else
sec = DefaultSeconds;
else
hour = DefaultHours;
min = DefaultMinutes;
sec = DefaultSeconds;
init(year, month, day, hour, min, sec, DefaultMillis);
valid = true;
catch (Exception e)
if (!valid)
throw new InvalidDateException("Invalid date: " + date + " for the specified format");
else if (format == FormatDB2TIMESTAMP || format == FormatUDBTIMESTAMP)
// 2002-02-04 10:49:30.999000 (UDB)
// 2002-02-04-10.49.30.999000 (DB2)
int year = Integer.parseInt(date.substring(0,4));
int month = Integer.parseInt(date.substring(5,7));
int day = Integer.parseInt(date.substring(8,10));
int hour = Integer.parseInt(date.substring(11,13));
int min = Integer.parseInt(date.substring(14,16));
int sec = Integer.parseInt(date.substring(17,19));
int millis = Integer.parseInt(date.substring(20,23));
init(year, month, day, hour, min, sec, millis);
else
init(date);
* Construct the date with the java.util.Date passed in.
public SlacDate(Date date)
init(date);
* Init the date with the java.util.Date passed in.
private void init(Date date)
Calendar cal = Calendar.getInstance();
cal.setTime(date);
init(cal);
* Return whether this date is after the date passed in.
* @d2 The date to compare against.
* @return Whether this date is after the date passed in.
public boolean after(SlacDate d2)
int xx = d2.getYear();
if (m_yyyy > xx)
return true;
else if (m_yyyy < xx)
return false;
else
xx = d2.getMonth();
if (m_mm > xx)
return true;
else if (m_mm < xx)
return false;
else
xx = d2.getDate();
if (m_dd > xx)
return true;
else if (m_dd < xx)
return false;
else
xx = d2.getHour();
if (m_hh > xx)
return true;
else if (m_hh < xx)
return false;
else
xx = d2.getMinute();
if (m_min > xx)
return true;
else if (m_min < xx)
return false;
else
xx = d2.getSecond();
if (m_ss > xx)
return true;
else if (m_ss < xx)
return false;
else
return (m_mil > d2.getMillisecond());
private void appendHoursMinutes(StringBuffer str, String separator)
if (m_hh < 10)
str.append(ZERO);
str.append(Integer.toString(m_hh));
if (!separator.equals(EMPTY))
str.append(separator);
if (m_min < 10)
str.append(ZERO);
str.append(Integer.toString(m_min));
private void appendTime(StringBuffer str, String separator, boolean addMillis)
appendHoursMinutes(str, separator);
if (!separator.equals(EMPTY))
str.append(separator);
if (m_ss < 10)
str.append(ZERO);
str.append(Integer.toString(m_ss));
if (addMillis)
if (!separator.equals(EMPTY))
str.append(separator);
if (m_mil < 100)
str.append(ZERO);
if (m_mil < 10)
str.append(ZERO);
str.append(m_mil);
* Version of the asString() method which defaults to FormatDDMMCCYY.
* <p>An example date in this format is:
* <pre>
* 25-02-1999
* </pre>
* @return The Date as a string in DDMMCCYY format.
public String asString()
return asString(FormatDDMMCCYY);
* Convert the date to a String. This will format the Date as defined by the format
* passed in. The default parameter is FormatDDMMCCYY.
* The valid formats are:
* <ul>
* <li>FormatDDMMCCYY</li>
* <li>FormatMMDDCCYY</li>
* <li>FormatDATETIME</li>
* <li>FormatDDMMTIME</li>
* <li>FormatTIMESTAMP</li>
* <li>FormatCCYYMMDD</li>
* <li>FormatCCYYMMDDHHMM</li>
* <li>FormatCCYYMMDDHHMMSS</li>
* <li>FormatDDMMCCYYTIME</li>
* <li>FormatDATEVERBOSE</li>
* <li>FormatDATETIMEVERBOSE</li>
* <li>FormatHHMMSS</li>
* <li>FormatHHMMSSMIL</li>
* <li>FormatDB2TIMESTAMP</li>
* <li>FormatUDBTIMESTAMP</li>
* </ul>
* @param format The format to return the string in.
* @return The date in string format (as specified by the format parameter).
public String asString(int format)
StringBuffer str = new StringBuffer(20);
if (format == FormatDB2TIMESTAMP || format == FormatUDBTIMESTAMP)
str.append(Integer.toString(getYear()));
str.append(HYPHEN);
int month = getMonth();
if (month < 10)
str.append(ZERO);
str.append(Integer.toString(month));
str.append(HYPHEN);
int day = getDate();
if (day < 10)
str.append(ZERO);
str.append(Integer.toString(day));
String dateTimeSeparator = new String();
if (format == FormatDB2TIMESTAMP)
dateTimeSeparator = HYPHEN;
else if (format == FormatUDBTIMESTAMP)
dateTimeSeparator = SPACE;
str.append(dateTimeSeparator);
String timeSeparator = new String();
if (format == FormatDB2TIMESTAMP)
timeSeparator = PERIOD;
else if (format == FormatUDBTIMESTAMP)
timeSeparator = COLON;
appendTime(str, timeSeparator, true);
str.append("000");
else if (format == FormatDATETIME || format == FormatMMMDDTIME || format == FormatTIMESTAMP)
str.append(getMonthNameAbbrev());
str.append(SPACE);
if (m_dd < 10)
str.append(ZERO);
str.append(Integer.toString(m_dd));
str.append(SPACE);
appendTime(str, COLON, false);
if (format == FormatDATETIME)
str.append(SPACE);
str.append(Integer.toString(m_yyyy));
else if (format == FormatTIMESTAMP)
str.append(COLON);
str.append(formattedMillis(m_mil));
else if (format == FormatHHMMSS)
appendTime(str, COLON, false);
else if (format == FormatHHMMSSMIL)
appendTime(str, COLON, true);
else if (format == FormatCCYYMMDD || format == FormatCCYYMMDDHHMM || format == FormatCCYYMMDDHHMMSS)
str.append(Integer.toString(m_yyyy));
if (m_mm < 10)
str.append(ZERO);
str.append(Integer.toString(m_mm));
if (m_dd < 10)
str.append(ZERO);
str.append(Integer.toString(m_dd));
if (format == FormatCCYYMMDDHHMMSS)
appendTime(str, EMPTY, false);
else if (format == FormatCCYYMMDDHHMM)
appendHoursMinutes(str, EMPTY);
else if (format == FormatDATEVERBOSE || format == FormatDATETIMEVERBOSE)
str.append(Integer.toString(m_dd));
if (m_dd > 10 && m_dd < 14)
str.append(DayExtension[0]);
else
str.append(DayExtension[m_dd%10]);
str.append(SPACE);
str.append(getMonthName());
str.append(SPACE);
str.append(Integer.toString(m_yyyy));
if (format == FormatDATETIMEVERBOSE)
str.append(",");
str.append(SPACE);
appendTime(str, COLON, false);
else
// DDMMCCYY, MMDDCCYY, DDMMCCYYTIME
int first;
int second;
if (format != FormatMMDDCCYY)
first = getDate();
second = getMonth();
else
second = getDate();
first = getMonth();
if (first < 10)
str.append(ZERO);
str.append(Integer.toString(first));
str.append(s_dateSep);
if (second < 10)
str.append(ZERO);
str.append(Integer.toString(second));
str.append(s_dateSep);
str.append(Integer.toString(getYear()));
if (format == FormatDDMMCCYYTIME)
str.append(SPACE);
appendTime(str, COLON, false);
return str.toString();
* Return whether this date is before the date passed in
* @d2 The date to compare against.
* @return Whether this date is before the date passed in.
public boolean before(SlacDate d2)
return (!after(d2) && !equals(d2));
* Clone the current date.
* @return The cloned SlacDate object
public Object clone()
SlacDate d = new SlacDate();
d.m_dd = m_dd;
d.m_mm = m_mm;
d.m_yyyy = m_yyyy;
d.m_hh = m_hh;
d.m_min = m_min;
d.m_ss = m_ss;
d.m_mil = m_mil;
return d;
* Compare this date with the supplied date.
* Hours, minutes, seconds and milliseconds are taken into consideration.
* Returns:
* -1 this date is before the supplied date.
* 0 this date is equal to the supplied date.
* 1 this date is after the supplied date.
public int compareTo(Object o2)
SlacDate d2 = (SlacDate)o2;
if (equals(d2))
return 0;
if (after(d2))
return 1;
return -1;
* Compare this date with the supplied date.
* Hours, minutes, seconds and milliseconds are NOT taken into consideration.
* Returns:
* -1 this date is before the supplied date.
* 0 this date is equal to the supplied date.
* 1 this date is after the supplied date.
public int compareDate(Object o2)
SlacDate baseDate = (SlacDate)o2;
SlacDate startBaseDate = new SlacDate(baseDate.getCalendar().getTime());
startBaseDate.setHour(0);
startBaseDate.setMinute(0);
startBaseDate.setSecond(0);
startBaseDate.setMillisecond(0);
SlacDate endBaseDate = new SlacDate(baseDate.getCalendar().getTime());
endBaseDate.setHour(23);
endBaseDate.setMinute(59);
endBaseDate.setSecond(59);
endBaseDate.setMillisecond(999);
int compare = 0;
if (before(startBaseDate))
compare = -1;
else if (after(endBaseDate))
compare = 1;
return compare;
* Compare this date with today's date.
* Hours, minutes, seconds and milliseconds are NOT taken into consideration.
* Returns:
* -1 this date is before today.
* 0 this date is equal to today.
* 1 this date is after today.
public int compareToToday()
return compareDate(today());
* Calculate the difference (in days) between the two dates.
* Note the difference may be negative.
* @param from The <i>start</i> date
* @param to The <i>to</i> date
* @return The difference between the dates in days.
public static int daysBetween(SlacDate from, SlacDate to)
int dayFrom;
int monthFrom;
int yrFrom;
int dayTo;
int monthTo;
int yrTo;
int mult = 1;
if (from.after(to))
mult=-1;
dayFrom = to.getDate();
monthFrom = to.getMonth();
yrFrom = to.getYear();
dayTo = from.getDate();
monthTo = from.getMonth();
yrTo = from.getYear();
else
dayFrom = from.getDate();
monthFrom = from.getMonth();
yrFrom = from.getYear();
dayTo = to.getDate();
monthTo = to.getMonth();
yrTo = to.getYear();
int cnt=0;
try
if (yrFrom != yrTo)
// Different Years.
for (int i=yrFrom+1; i<yrTo; i++)
cnt += SlacDate.daysInYear(i);
for (int i=monthFrom+1; i<13; i++)
cnt+=daysInMonth(i, yrFrom);
for (int i=1; i<monthTo; i++)
cnt+=daysInMonth(i, yrTo);
cnt += (daysInMonth(monthFrom, yrFrom)-dayFrom);
cnt += dayTo;
else
if (monthFrom != monthTo)
// Same Year but different months.
for (int i=monthFrom+1; i<monthTo; i++)
cnt+=daysInMonth(i, yrFrom);
cnt += (daysInMonth(monthFrom, yrFrom)-dayFrom);
cnt += dayTo;
else
// Same Year and month.
cnt += (dayTo-dayFrom);
catch (InvalidDateException ide)
// This should never happen
return cnt * mult;
* Calculate the number of days from the specified date.
* Note the difference may be negative.
* @param date The date to calculate from
* @return The diference between the two dates in days (may be negative).
public int daysFrom(SlacDate date)
return daysBetween(date, this);
* Calculates the number of days in a given month in a given year
* copes with century dates!
* @param month The month to determine the day count
* @param year The year the month is in (only relevant for February).
* @exception InvalidDateException Invalid parameters passed in. Ie the month was >= 12
* or the month was < 0.
public static int daysInMonth(int month, int year) throws InvalidDateException
if (month > 12 || month <= 0)
throw new InvalidDateException("Invalid month specified to SlacDate.daysInMonth(): " + month);
// month-1, because DaysInMonth array is 0-based.
return (month == FEBRUARY && isLeapYear(year)) ? 29 : DaysInMonth[month-1];
* Calculates the number of days in a given year.
* @param year The year the month is in (only relevant for February).
public static int daysInYear(int year)
return (isLeapYear(year)) ? 365 : 364;
* Calculate the number of days to the specified date.
* Note the difference may be negative.
* @param date The date to calculate to
* @return The diference between the two dates in days (may be negative).
public int daysTo(SlacDate date)
return daysBetween(this, date);
* Decrement the date by the specified number of years, months and days.
* @param years The number of years to increment by
* @param months The number of months to increment by
* @param days The number of days to increment by
public void decrement(int years, int months, int days)
decrementYears(years);
decrementMonths(months);
decrementDays(days);
* Decrement the date by the specified number of days.
* @param days The number of days to decrement by
public void decrementDays(int days)
incrementDays(days * -1);
* Decrement the date by the specified number of hours.
* @param hours The number of hours to decrement by
public void decrementHours(int hours)
incrementHours(hours * -1);
* Decrement the date by the specified number of milliseconds.
* @param seconds The number of seconds to decrement by
public void decrementMilliseconds(int milliseconds)
incrementMilliseconds(milliseconds * -1);
* Decrement the date by the specified number of minutes.
* @param minutes The number of minutes to decrement by
public void decrementMinutes(int minutes)
incrementMinutes(minutes * -1);
* Decrement the date by the specified number of months.
* @param years The number of months to decrement by
public void decrementMonths(int months)
incrementMonths(months * -1);
* Decrement the date by the specified number of seconds.
* @param seconds The number of seconds to decrement by
public void decrementSeconds(int seconds)
incrementSeconds(seconds * -1);
* Decrement the date by the specified number of years.
* @param years The number of years to decrement by
public void decrementYears(int years)
incrementYears(years * -1);
* Calculate the difference between two dates to the nearest second as a String.
* @param from The start date
* @param to The end date
public static String differenceBetween(SlacDate from, SlacDate to)
SlacDate f, t;
if (from.after(to))
t = from;
f = to;
else
t = to;
f = from;
int secs = 0;
int mins = 0;
int hours = 0;
int days = 0;
int months = 0;
int years = 0;
secs = t.getSecond() - f.getSecond();
mins = t.getMinute() - f.getMinute();
hours = t.getHour() - f.getHour();
days = t.getDate() - f.getDate();
months = t.getMonth() - f.getMonth();
years = t.getYear() - f.getYear();
if (secs < 0)
secs += 60;
mins--;
if (mins < 0)
mins += 60;
hours--;
if (hours < 0)
hours += 24;
days--;
if (days < 0)
try
days += daysInMonth(f.getMonth(), f.getYear());
catch (InvalidDateException ide)
days += 30;
months--;
if (months < 0)
months += 12;
years--;
StringBuffer sb = new StringBuffer();
sb.append(years).append(s_dateSep);
sb.append(months).append(s_dateSep);
sb.append(days).append(SPACE);
sb.append(hours).append(COLON);
sb.append(mins).append(COLON);
sb.append(secs);
return sb.toString();
* Calculate the difference between the date passed in and this date.
* Note that if the date passed in is in the future the difference will be
* negative.
* @param from The date from which to return the difference
* @return The difference from the date passed in in String format
public String differenceFrom(SlacDate from)
return differenceBetween(from, this);
* Calculate the difference between this date and the one passed in.
* Note that if the date passed in is in the past the difference will be
* negative.
* @param to The date to which to return the difference
* @return The difference to the date passed in in String format
public String differenceTo(SlacDate to)
return differenceBetween(this, to);
* Return whether the two dates are the same. This will check right down to the second.
* @param d2 The date to compare against
* @return Whether the dates are the same.
public boolean equals(SlacDate d2)
return ((m_yyyy == d2.m_yyyy) &&
(m_mm == d2.m_mm) &&
(m_dd == d2.m_dd) &&
(m_hh == d2.m_hh) &&
(m_min == d2.m_min) &&
(m_ss == d2.m_ss) &&
(m_mil == d2.m_mil));
public String format(DateFormat df)
Calendar cal = getCalendar();
return df.format(cal.getTime());
private final String formattedMillis(int millis)
String rString = null;
if (millis < 10)
rString = "00" + millis;
else if (millis < 100)
rString = ZERO + millis;
else
rString = EMPTY + millis;
return rString;
public Calendar getCalendar()
Calendar cal = Calendar.getInstance();
cal.set(m_yyyy, m_mm-1, m_dd, m_hh, m_min, m_ss);
cal.set(Calendar.MILLISECOND, m_mil);
return cal;
* Return the Date/Time in CCYYMMDD format.
* <p>An example date in this format is:
* <pre>
* 19990225
* </pre>
* @return The Date as a string in CCYYMMDD format.
public String getCCYYMMDD()
return asString(FormatCCYYMMDD);
* Return the Date/Time in CCYYMMDDHHMM format.
* <p>An example date in this format is:
* <pre>
* 199902251423
* </pre>
* @return The Date as a string in CCYYMMDDHHMM format.
public String getCCYYMMDDHHMM()
return asString(FormatCCYYMMDDHHMM);
* Return the Date/Time in CCYYMMDDHHMMSS format.
* <p>An example date in this format is:
* <pre>
* 19990225142356
* </pre>
* @return The Date as a string in CCYYMMDDHHMMSS format.
public String getCCYYMMDDHHMMSS()
return asString(FormatCCYYMMDDHHMMSS);
public int getDate() { return m_dd; }
* Return the date in DATETIME format.
* <p>An example date in this format is:
* <pre>
* Feb 25 14:21:09 1999
* </pre>
* @return The Date as a string in DATETIME format.
public String getDATETIME()
return asString(FormatDATETIME);
* Return the Date/Time in DATETIMEVERBOSE format.
* <p>An example date in this format is:
* <pre>
* 25th February 1999, 14:21:09
* </pre>
* @return The Date as a string in DATETIMEVERBOSE format.
public String getDATETIMEVERBOSE()
return asString(FormatDATETIMEVERBOSE);
* Return the Date/Time in DATEVERBOSE format.
* <p>An example date in this format is:
* <pre>
* 25th February 1999
* </pre>
* @return The Date as a string in DATEVERBOSE format.
public String getDATEVERBOSE()
return asString(FormatDATEVERBOSE);
* Return the day o -
Validate Date Range - Javascript
Hi Gang,
This is close to a repost... but more of a followup to a
thread that has
already moved down everyones list.
I have a pretty simple form validation routine I need to
implement, but I
don't know the Javascript syntax well enough to work it out
(my background
is VBscript, but this needs to be client side). I received
some good URL's
to check out some free scripts.. but unfortunately, I don't
know javascript
well enough to hack them up correctly.
If someone can help out with a bit of code, it would be a
huge help.
What I need to do is validate a numeric range as well as not
leaving the
field blank.
For example what is entered must be a number between 1900 and
2006.
Here is what I am using for the basic required function:
The name of the form is "ThisForm_Right", and the field name
is "DOB_Year"
(to explain the piece in the code below)
if (ThisForm_Right.DOB_Year.value=="")
alert ("Please enter the YEAR of your DOB.");
ThisForm_Right.DOB_Year.focus();
return false;
Can some kind sole help with a modified version to also check
for an entered
number range?
I suspect some sort of "And" statement, Like
If
ThisForm_Right.DOB_Year.Value==""
AND
Year.Value NOT between (1900 and 2006)
alert ("Please enter the YEAR of your DOB between 1900 and
2006.");
ThisForm_Right.DOB_Year.focus();
return false;
I just don't know the real syntax :>
Thanks
-D>thanks you so much for the code, I'll test it out and
reply with >the
>results.
Shouldn't that be "Thanks so much for the Cod"?
"Dave Bar" <[email protected]> wrote in message
news:e28c7t$hk1$[email protected]..
> ahh yes, you are right..
> I should have said OR instead of AND.
> If Field is blank OR range is not between 1900 &
2006. Thanks for catching
> and pointing that out.
>
> thanks you so much for the code, I'll test it out and
reply with the
> results.
> Thanks
> -Dave
>
>
>
>
> "Lionstone" <[email protected]> wrote
in message
> news:e28b1a$fu5$[email protected]..
>> That's probably because you asked for a fish to help
you out
>>
>>> Can some kind sole help with a modified version
to also check for an
>>> entered
>>> number range?
>>
>> and fish can't type.
>>
>> You're off on the logic though, since something is
not likely to be both
>> blank and outside a certain number range. If it's
blank or outside the
>> range, either condition is sufficient for an error,
right?
>> You also want to make sure that no letters, etc, are
entered, because
>> that will mess up your comparisons to the other
numbers. Keeping in mind
>> that javascript validation can be defeated by
sneezing and you'll need to
>> re-validate on the server, this will be closer to
right (not tested).
>>
>> var ThisYear = ThisForm_Right.DOB_Year.value;
>> ThisYear = ThisYear.replace(/[^/d]/g,"");
>> if(ThisYear.length == 0)
>> {
>> alert("Please enter the year of your DOB.");
>> ThisForm_Right.DOB_Year.focus();
>> return false;
>> }
>> else
>> {
>> ThisYear = parseInt(ThisYear);
>> if((ThisYear < 1900) || (ThisYear > 2006))
>> {
>> alert ("The year of your DOB must be between 1900
and 2006.");
>> ThisForm_Right.DOB_Year.focus();
>> return false;
>> }
>> }
>>
>>
>
> -
How to compare data between two tables?
Hi,
My team is trying to develop a SAP data migration tool (DMT) using ABAP.
One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
Any help would be greatly appreciated, thanks!Hi Kian,
Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
Thanks,
Vinay -
Validate Date Range in inputDate component
Hi
I am using JDev 11.1.1.2.0
I have an inputDate component which on click i need to give dates from today to future dates not passed dates.
So i have included 'validate date time range' component in the inputDate component and in the minimum property i have declared 'adf.currentDate' using expression builder and set the maximum as Jan 31,2099.
But when i execute my application i am able to select passed dates using the inputDate component, please help how can i check the date using a validator in inputDate component.
Thanks
Sudeepya i had tried with that property too....
i have declared minValue as adf.currentDate and on that it changes the value of maxValue to current date in Jan 3,2012
i have convertDatetime component in my inputDate to display the selected date in certain format.
It gives error as the format doesnot matches with the convertDatetime and inputDate component.
How can i use the minValue and maxValue of inputDate component?
the component:-
<af:inputDate
label="Planned Termination Date"
id="id2"
value="#{modifyuser.pterminationdate}"
valueChangeListener="#{modifyuserfields.plannedTermDate}"
minValue="adf.currentDate" maxValue="2099-12-31">
<af:convertDateTime pattern="dd-MMM-yyyy"/>
</af:inputDate> -
Validate Date and block JavaScript page change
how I can validate date acrobat, can block JavaScript page change, only change with a button?
If you use the "util.scand" method date validation is part of the process. It either returns the number of milliseconds from the Epoch date used by JavaScript for the date time object the null value.
Date Arithmetic has some sample scripts, but you need to keep in mind that Date and Time are not independent and using "new Date()" returns the date and time at the time that line of code is executed and that can cause issues for the computing of dates only.
Are you sure of day count, most differences include the start and end dates in the number of days for the calculation.
Custom calculation for today's date field (format is None):
// get today's date an time
var oToday = new Date();
// set to start of day
oToday.setFullYear(oToday.getFullYear(), oToday.getMonth(), oToday.getDate(), 0, 0, 0, 0)
// set field value
event.value = util.printd("d/mm/yyyy", oToday);
Custom calculation for the difference in days field (format None):
var cEnteredDate = this.getField("EnteredDate").value;
var cToday = this.getField("Today").value;
event.value = "";
if(cEnteredDate != "" && cToday != "") {
// process only if date values not empty
// convert date strings to date time objectat midnight
var oEnteredDate = util.scand("d/mm/yyyy", cEnteredDate );
if (oEnteredDate == null) {
app.alert("Error in processing entered date", 2, 0);
oEnteredDate.setFullYear(oEnteredDate.getFullYear(), oEnteredDate.getMonth(),oEnteredDate.getDate(), 0, 0, 0, 0)
var oToday = util.scand("d/mm/yyyy", cToday);
if(oToday == null) {
app.alert("Error converting today", 2,0);
oToday.setFullYear(oToday.getFullYear(), oToday.getMonth(),oToday.getDate(), 0, 0, 0, 0)
// convert date objects to days
var nEnteredDate = Math.floor(oEnteredDate.getTime() / (1000 * 60 * 60 * 24));
var nToday = Math.floor(oToday.getTime() / (1000 * 60 * 60 * 24));
// compute & format the difference
event.value = util.printf("%,0 1.0f", (nToday - nEnteredDate)); -
Best way to pass secure data between servers
Hello,
In the not to distant future my company wants to expand our
site to include a single sign-on, this will be made possible with
the 3rd party group that handles our customer info. Can someone
enlighten me as the most secure method of transferring user data
between these locations?
What has been proposed is to pass the login from our site to
the 3rd party, if successful pass back certain data, display and
possibly update on our site and then pass this back to the 3rd
party server.
Is CFLogin the most powerful method for login? I've used
query checks in the past, is that adequate or is CFLogin much
better? Any pointers are appreciated."Is CFLogin the most powerful method for login? I've used
query checks
in the past, is that adequate or is CFLogin much better?"
Neither, CFLogin is really just a specific purpose IF block.
Code
within the opening and closing <cflogin...> tags is run
when a user is
not logged in with the <cfloginuser...> tag. Inside
this block one
still needs to validate the credentials provided by the user,
often with
a query check.
The <cflogin...><cfloginuser...> combination
provides an easy to
interpret and use mechanism to run conditional code and
persist a user
login state from request to request. It is basically
equivalent to ones
own <cfif...> logic combined with session data for the
user state.
Under the hood it is using the same mechanisms.
I usually prefer to roll my own solution because I often want
to store
more state data about a user then is allowed with the
<cfloginuser...>
tag and the related getAuthUser() and isUserInRole()
functions. -
Hi all,
I am receiving date (day,month,year) from the file.Now i want to validate this date .
Please let me know if any function module available for this.
Regards,
ShobanHI Shoban,
u can check the date with the FM K_POSTING_DATE_CHECK
or else if u didnt get means just search in se37 by typing DATE or CHECK k u can fine lot of FM so check there k
or else individual fields u can check i mean date between 1 to 31 and month in between 1 to 12 like year also
THX -
Hi everyone,
I am having issues with a couple of BlackBerry's, where they are receiving a message on their phone saying:
"This message is used to carry data between the BlackBerry handheld and an associated server. Please do not delete, move or respond to this message - it will be processed by the server."
Email is from "[email protected]"
This has only appeared since installing the BlackBerry Desktop Software version 6.
We have used the link below which resolved the issue on one of the BlackBerry's but on the other neither of the options are there.
http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB04254&sliceId=SAL_Pub...
The link I have just posted references to version 5, just wondered if anyone knows how to resolve it in version 6 or some other option. Original email is still received fine but want to stop the other email about "This message is used to carry data between.......".
Thanks in Advance.
KevinAn alternative, if you cannot stop it via the two recommended fixes, is to send those messages to your jiunk folder at the email server level so that they never reach your BlackBerry...
1. If any post helps you please click the below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
I need to copy data between two cubes (through a business rule). Can I do it using Partition/Replication? If so, does anyone have an example on how it is done? I'm currently using @XREF, but that does not transfer data for blocks that don't already exist in target database.
I'm very new to this so a detailed description will help.
Thanks for your help.Yes, partitions are great. I like to use replicated partitions because I can control the data, and deal with integrity issues etc. Your usage may vary.
Basically, you go to your "Source" database, go to the partitions menu, and "Create New Partition". You then walk through each of the tabs in the partition menu
Type Tab: Choose the type. Let's say a "replicated" partition.
Connection Tab: Choose what databases will be connected with the partition
Areas Tab: I like to check the "Use Text Editor" to just type out the formulas. Also check the "Show Cell Count" to have some confidence your formulas are working as planned. Here you define what data moves from source to target. For example I might setup the following
Source:
("Actuals Data"),
@LEVMBRS("Province",0),
@GENMBRS("Company",2)
Target:
("Actuals Data"),
@LEVMBRS("Province",0),
@GENMBRS("Company",2)
If the names don't match, you can adjust that in the advanced properties or mapping properties. (If you have multiple slices of data - use the advanced mapping).
Now validate and save -
Validate Data Infocube "External Services - 0SRV_C01"
Hi all,
I've activated External Services Infocube and now i have to validate agains R3.
Does anybody know how can i validate it please ? i mean transaction code, report, etc ; because of i have loaded initial load, the i executed a delta load (0 records) but when i compared the data agains ESLL there area a lot of missing records in BW ; so i dont understand how its works.
Any comments about it will be a apprecite it.
I will assign point if useful.
RegardsPlease, if someone knows something about this issue i really appreciate.
I still checking the data between R3-BW and i dont get the extractor because of there are a lot of Purchase Order of services that did not extracted by 2lis_02_s174
THANKSSSSSSSSSSs -
I have a client with a BlackBerry Pearl 8110. It was (is) configured to receive email from a Microsoft Exchange Server via his Outlook account. I have uninstalled the Desktop Manager and re-installed ensuring the computer transmits his email via the Re-Director. All settings in the Desktop Manager are correct. The phone was working fine for over 5 years. Now he is getting emails both on his phone and in Outlook saying:
This message is used to carry data between the BlackBerry handheld and an associated server. Please do not delete, move or respond to this message - it will be processed by the server.
I have verified that his phone is not attempting to perform the Enterprise Activation process by checking :
Options > Advanced Options > Enterprise Activation.
He does however have a Service Book entitled "CMIME"
How can I resolve this issue?Is the user needing the Redirector service?
Step 1: If you're not using Redirector or Enterprise, you should uninstall Desktop Manager and then reinstall it using the BlackBerry Internet Service option.
Step 2: On your device, go to: Options > Advanced > Service Book, and delete all service books for [Desktop]
1. If any post helps you please click the below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
Date between sysdate-50 and sysdate problem
hi,
i have a big big problem and i need some help
I have oracle 8i and 10g databases installed at work. i have a problem with an select statement that brings data from 3 tables.
The select looks like this:
select mms_id, img_id, mms_usr_id as usr_id, mms_pvd_id, mms_data as data
from vsc_mms vm, vsc_image vi, vsc_user vu
where img_mms_id = mms_id
and mms_usr_id = usr_id and usr_client_id = cli
and img_mms_id <> 0
and mms_status =0
and mms_data between data_ini and data_end .......is not very important; the joins are made all right. What is important is that:
vsc_mms has aprox. 3.000.000 recordings
vsc_image has, also, aprox. 3.000.000 recordings.
select count(distinct img_date) from vsc_image =657.021
select count(distinct mms_data) from vsc_mms >=600.000
On both tables there are, among other, index on mms_data, img_date.
Now, my data_ini and data_end come from java (user send data_ini and data_end through http:// ) OR i can put this select in a procedure like:
declare
datai date:=to_date('20.01.2006','dd.mm.yyyy');
datae date:=to_date('30.01.2006','dd.mm.yyyy');
......my select ..... and mms_data between data_ini and data_end
the select takes on 8i more than 30 seconds. the same select takes on 10G quite same long time. i also run the select using
and mms_data between sysdate-50 and sysdate and i got the same long time.
Also important: this select brings almost 30 recordings; when the restrictions are too severe and the count(*) =0 the result is brought in 0.01 seconds; outherwise, when count(*) >1, is ruinous.
But, if i put and mms_data between to_date('20.01.2006','dd.mm.yyyy') and to_date('30.01.2006','dd.mm.yyyy'), the response come in 1 seconds or less.
1. Can someone help me and tell me why i got this long time for response when i use sysdate or when receiving data_ini, data_end like parameters from java
2. is it true that for a better usage of a index, the procent of repeatedly recordings has to be small? I mean when i have 600.000 distinct recordings from 3.000.000 is it good or not to use index on that column?
thanks in advanceThere can be some difference in how Oracle builds execution plan when
you are using binding variables and explicit values:
SQL> create index idxtbl1 on tbl1(date#);
Index created.
SQL> insert into tbl1 select sysdate-rownum from (select 1 from dual connect by lev
200000 rows created.
SQL> create index idxtbl1 on tbl1(date#);
Index created.
SQL> analyze table tbl1 compute statistics for all indexes;
Table analyzed.
SQL>set autotrace traceonly
SQL> var a1 varchar2(20)
SQL> var a2 varchar2(20)
SQL> select * from tbl1 where date# between to_date('01/01/1900','dd/mm/yyyy')
2 and to_date('01/01/1901','dd/mm/yyyy');
365 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=3 Card=365 Bytes=3
285)
1 0 INDEX (RANGE SCAN) OF 'IDXTBL1' (INDEX) (Cost=3 Card=365 B
ytes=3285)
Statistics
0 recursive calls
0 db block gets
28 consistent gets
0 physical reads
0 redo size
6809 bytes sent via SQL*Net to client
772 bytes received via SQL*Net from client
26 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
365 rows processed
SQL> exec :a1 := '01/01/1900'
PL/SQL procedure successfully completed.
SQL> exec :a2 := '01/01/1901'
PL/SQL procedure successfully completed.
SQL> select * from tbl1 where date# between to_date(:a1,'dd/mm/yyyy')
2 and to_date(:a2,'dd/mm/yyyy');
365 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=495 Bytes=4
455)
1 0 FILTER
2 1 INDEX (RANGE SCAN) OF 'IDXTBL1' (INDEX) (Cost=4 Card=495
Bytes=4455)
Statistics
0 recursive calls
0 db block gets
28 consistent gets
0 physical reads
0 redo size
6809 bytes sent via SQL*Net to client
772 bytes received via SQL*Net from client
26 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
365 rows processedRgds. -
am trying to back up and transfer data between two hard drives but cant get up twp Hd icons at the same time. It is so easy in windows but cant seem to do it in MBPro. Even Dick Smith couldnt help me today.
It is probaly so easy it everyone will LOL but I cant get it happening.
TIA RobboDo the HD icons appear on your Desktop?
If not, adjust your Finder preferences:
Also check "Hard Disks" if you want your internal HD to appear on the Desktop.
Open one, open the other, should be no problem.
Maybe you are looking for
-
Mac OSX Yosemite crashes alot with random tasks in Photoshop CC2014
\Mac OSX Yosemite crashes all the time with random tasks in Photoshop CC. Now almost nothing works. Sometimes it stops working after doing random tasks like starting photoshop and i have to do a hard reset by putting the power off of my Mac pro retin
-
Why are pdf not coding right?? I have 2 macbook pros 15
Pdfs in lion are coming accross as windat files not pdfs.. but they are working fine on windows pc's this needs fixed fast as it is messing up business flow Please advise
-
Dear Experts, This requirement is for an IT service project. The process is - I have two company codes Comp code 1 & Comp code 2, In which Project is created in company code 1. Employees are assigned to project to onsite & offshore from company code
-
I know this is a little late, but does anyone know if this deal which gives an ipod touch with the purchase of a new mac computer will be coming to Australia? I want to get an MacBook, but I heard that "Often times the deals Apple offers are offered
-
SXMB_MONI transaction table
Hi, Does anyone know which ABAP table is sxmb_moni transactions is stored? Thanks, Gowri