How to validate a datetime in a string

Hi Team,
I have a string,How can i validate whethere the string contains a valid datetime or not ?
Thanks in advance.
Regards
Subrat

Hi Subrat,
Look at this excerpt from website:
While there are functions to check if a value is a date (IsDate) or a time (IsTime), PowerBuilder provides no function to check if a value is a valid DateTime. A function to convert to DateTime and check if the value is a valid DateTime is provided in a tip on this site.
HTH,
Manuel Marte

Similar Messages

  • How to validate the Email string

    Hi all,
    How do you validate for a valid email string under regular expressions?
    Regards
    David

    Hi,
    Create an validation on EMAIL item and select Regular Expression as a validation method.
    Write the below coding in the regular expression validation method.
    ^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|co.in|in|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$
    Regards,
    Sakthi.
    Edited by: Sakthi on Mar 18, 2011 2:22 AM
    Edited by: Sakthi on Mar 18, 2011 2:28 AM

  • How to validate "string" in multirecord block

    Francois,
    Thanks for reply,
    Acually Kevin used the summary functions in different text items and the 'comparision' function is being called in one of the text item which is having datatype as number, but in case of character we cannot use formula and summary function. May be i am not able to put the things at right place.
    Plz explain in detail.
    Thanks in advance
    azhar

    Francois,
    Thanks for reply,
    Actually i have tried many possible ways to validate the same form for string but i did not get sucess. What i request u to please make the same form as directed by kevin and suggest me where i have to make changes for which it start validating the string also.
    thanks in advance
    azhar

  • 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

  • How to validate the file path when downloading.

    Hi
    How to validate the file path when downloading to Presentation or application Server.

    hiii
    you can validate file path by following way
    REPORT zvalidate.
    TYPE-POOLS: abap.
    DATA: w_direc TYPE string.
    DATA: w_bool TYPE abap_bool.
    w_dir = 'c:\Myfolder\'.
    CALL METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
    directory = w_direc
    RECEIVING
    result = w_bool
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    wrong_parameter = 3
    not_supported_by_gui = 4
    OTHERS = 5.
    IF NOT w_bool IS INITIAL.
    WRITE:/ 'Directory exists.'.
    ELSE.
    WRITE:/ 'Directory does not exist.'.
    ENDIF.
    regards
    twinkal

  • Create a Business Rule to validate a datetime field

    Hi friends,
    I'm trying to create a business rules to validate a datetime attribute.
    I tried to use the Validation "must contain the pattern" but I don't kwnow exactly how it works.
    In the Edit Action section I have 3 options:
    - Attribute value
    - Attribute
    - Blank
    Where should I write the RegExp?
    Any comment will be appreciated.
    Kinde Regards,
    Paul

    Hi superbluesman,
    thanks for your quick answer.
    I created this expression to validate my specific date format and it works:
    ^(0[1-9]|1[012]|[1-9])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
    Kind Regards,
    Paul

  • HELP! How to validate DATE?

    Hello...
    how to validate a DATE variable?
    I have used SimpleDateFormat (dd/MM/yyyy).
    For some input it worked fine, but for:
    12/67/200394 (OK!) <- this is false, right? but not trapped!
    1234546 (TRAPPED!)
    12/324/1234 (OK!) <- this is false, right? but not trapped!
    I need to have a 100% working Date validator.
    Plz Help.
    Thank you.

    Hey -
    I used to following code on your dates to get the results you were looking for...
    import java.text.SimpleDateFormat;
    import java.text.ParsePosition;
    import java.util.Date;
    public class DateFormatTest {
         public static void main(String[] args) {
              SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
              df.setLenient(false);
              ParsePosition pos = new ParsePosition(0);
              String strDate = " 12/67/200394";
              Date date = df.parse(strDate, pos);
                    // Check all possible things that signal a parsing error
              if ((date == null) || (pos.getErrorIndex() != -1)) {
                   System.out.println("Error: " + pos.getIndex());
                   if (date == null) {
                        System.out.println("Date is null");
                   if (pos.getErrorIndex() != -1) {
                        System.out.println("Error index: " + pos.getErrorIndex());
    }I hope there's something helpful in there
    Lee

  • How to validate XML using java_xml_pack-summer-02?

    In jaxp1.1, we validate the xml file in this way:
    c:\java -jar Validator.jar myBookStore.xml
    However, in java_xml_pack-summer-02, which is latest version of jaxp, the Validator.jar is not available. So, how to validate xml file?
    Pls help.

    develop your own validator... here is a quick and dirty one, which spits exceptions when error are met:
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    public class Validator
      public static void main(String[] args) throws Exception {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setValidating(true);
        spf.setNamespaceAware(true);
        SAXParser sp = spf.newSAXParser();
        sp.parse(new File(args[0]), new DefaultHandler());
    }

  • How to Validate this using Regular Expressions

    Hi All,
    I have following types of Mail IDs, Each is a String.
    It may be either of the Following:
    [email protected]
    or
    Ameer<[email protected]>
    Then How to validate using the Regular Expressions.

    use this regex.. might need to convert it from perl regex flavor:
    (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
    \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
    ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
    \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
    31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
    ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
    (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
    (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
    ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
    r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[
    \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)
    ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
    )*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[
    \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
    )(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
    *:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
    |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
    \n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:
    \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
    ]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031
    ]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](
    ?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?
    :(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?
    :\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?
    :(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?
    [ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\]
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|
    \\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>
    @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"
    (?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?
    :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[
    \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-
    \031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(
    ?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;
    :\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([
    ^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
    .\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\
    ]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
    [\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\
    r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\]
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]
    |\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0
    00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\
    .|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
    ;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?
    :[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
    ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]
    ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
    ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
    ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
    \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
    ])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
    ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
    :\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
    \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
    [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\
    ]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
    ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["
    ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
    ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
    @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
    \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
    ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
    \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
    "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
    *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
    +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
    .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
    ?:\r\n)?[ \t])*))*)?;\s*)

  • How to validate input's in selection-screen

    Hi ,
    can any one how to validate input's field's  in selection-screen and each field has diffirent tables and what is the table name which has all the validating fields??
    Thank's in advance..

    hi,
      You can use validate selct-options using select query by obtaining the realtionship from table .Using the selection-screen events You can write code for validation as follows.
    tables:
      kna1.                                " General Customer data
    *"Selection screen elements............................................
    select-options:
      s_kunnr for kna1-kunnr.              " Customer number
    *"Data declarations...................................................
    Data declaration of the structure to hold kna1 details              *
    data:
      begin of fs_customer,
        kunnr type kna1-kunnr,             " Customer number
        adrnr type kna1-adrnr,             " Address
        anred type kna1-anred,             " Title
        erdat type kna1-erdat,             " Created on
        ernam type kna1-ernam,             " Created by
      end of fs_customer.
    *"Constants declarations..............................................
    constants
      w_path type string value 'D:\DOWNLOAD\CUSTOMER'.
    Internal table to hold customer details                             *
    data:
      t_customer like
        standard table
              of fs_customer.
                          AT SELECTION SCREEN OUTPUT                    *
    at selection-screen.
      perform retrieve.
    Form  RETRIEVE                                                     *
    This subroutine retrieve customer data from table kna1             *
    There are no interface parameters to be passed to this subroutine. *
    form retrieve .
      select kunnr                         " Customer number
             adrnr                         " Address
             anred                         " Title
             erdat                         " Created on
             ernam                         " Created by
        into corresponding fields of table t_customer
        from kna1
       where kunnr in s_kunnr.             " END SELECT
      if sy-subrc ne 0.
        message text-001 type 'E'.
        exit.
      endif.                               " IF SY-SUBRC NE 0
    endform.                               " RETRIEVE
    regards,
    veeresh

  • How to validate Email Address in HTML DB Application

    Hi,
    I have delevoped one Employee Login Details form in HTML DB. But i am unable to validate that email address as i find html db is not supporting String functions like indexOf(char c), substring(int) ect. So please can anybody help me to know how to validate email address that it has @ and . symbol or not.
    Thanks in advance.

    user529382,
    You may be able to use Regular Expressions instead, if you do a search in this forum for 'regex' you should find a few hits.
    While I agree that using a regular expression is a great way to verify that the user has entered an email address that conforms to the regular expression rules, it is still nothing more than that....conforming to the regular express rules.
    The only way to 100% confirm that an email address is 'valid', is to actually send an email to it, so what I tend to do is to get the user to enter their email twice (in a user registration screen for example), that way you can minimize the chance of 'typos', then send out a 'verification email' that the user has to click a link on to verify they have received it (I'm sure you've seen this type of system before), only when the confirmation is received would I then make the account 'active'.
    Hope this helps.

  • How to Validate SubmitButton

    Hi Firends,please see my requirement as below,
    1)i have a page that contains only one dropdowlist suppliername, go button and table region,user select supplier from dropdown and click the go button all the supplier information getting populate into table region.
    2)in table region i have a button called addsupplier to detail, user can select check box associated wih any row and click add supplier to deatil , selected supplier information going to supplier detail page,up to this OK.
    3)Now waht is the problem is , first time page gets render, user will not select any supplier from dropdown and also not clicking go button also , simply user clcik the addsupplier to detail button , i am getting error.
    so how to validate addsupplier to detail button, suppose user should not select any row in table region.
    i hope requirement is clear you guys.please help me out....
    Thanks
    vamshi

    Hi Sumit, Thanks for your quick reply.
    but i am not getting any null pointer exception. the error below as follows...
    Exception Details.
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT
    MV.VENDOR_ID,
    MV.VENDOR_NAME,
    MV.VENDOR_SITE_CODE,
    MDVS.CITY,
    MDVS.STATE,
    MDVS.COUNTRY,
    MVA.STATUS,
    MVA.STATUS_UPDATE_DATE
    FROM MODPOS_VENDOR_COMPS MV,MODPO_DISTINCT_VENDOR_SITES_V MDVS,MODPOS_QUOT_STG MQS,MODPOS_VENDOR_ASSES MVA
    WHERE MV.VENDOR_ID=MDVS.VENDOR_ID
    AND MDVS.VENDOR_SITE_CODE=MV.VENDOR_SITE_CODE
    AND MVA.VENDOR_ID=MV.VENDOR_ID
    AND MVA.VENDOR_SITE_CODE=MV.VENDOR_SITE_CODE
    AND MQS.AAM_PRODUCT=MV.PRODUCT_NAME
    AND MQS.COMPONENT_TYPE=MV.DIR_MATERIAL_NAME
    AND MQS.PROCUREMENT_CATEGORY=MV.PURC_COMMODITY
    AND MQS.BUSINESS_UNIT=MV.BUSINESS_UNIT
    AND MQS.AAM_PRODUCT LIKE NVL(:1,MQS.AAM_PRODUCT)
    AND MQS.COMPONENT_TYPE LIKE NVL(:2,MQS.COMPONENT_TYPE)
    AND MQS.PROCUREMENT_CATEGORY LIKE NVL(:3,MQS.PROCUREMENT_CATEGORY)
    AND MQS.BUSINESS_UNIT LIKE NVL(:4,MQS.BUSINESS_UNIT)
    AND MV.VENDOR_NAME LIKE NVL(:5,MV.VENDOR_NAME)
    at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888)
    at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1064)
    at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1294)
    at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2396)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1512)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:463)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:384)
    at OA.jspService(OA.jsp:40)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
    at java.lang.Thread.run(Thread.java:534)
    ## Detail 0 ##
    java.sql.SQLException: ORA-01008: not all variables bound
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:583)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2548)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2933)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:650)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:578)
    at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:627)
    at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:515)
    at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3289)
    at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(OAJboViewObjectImpl.java:1207)
    at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4146)
    at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:567)
    at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:531)
    at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2343)
    at oracle.jbo.server.ViewRowSetIteratorImpl.first(ViewRowSetIteratorImpl.java:1224)
    at oracle.jbo.server.ViewRowSetImpl.first(ViewRowSetImpl.java:2347)
    at oracle.jbo.server.ViewObjectImpl.first(ViewObjectImpl.java:5167)
    at xxaam.oracle.apps.pos.quotstg.webui.AddSupplierCO.processFormRequest(AddSupplierCO.java:185)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:734)
    at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:352)
    at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:943)
    at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1546)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:929)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:895)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:751)
    at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:352)
    at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:373)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:929)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:895)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:751)
    at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:352)
    at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:340)
    at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2392)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1512)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:463)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:384)
    at OA.jspService(OA.jsp:40)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
    at java.lang.Thread.run(Thread.java:534)
    java.sql.SQLException: ORA-01008: not all variables bound
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:583)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2548)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2933)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:650)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:578)
    at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:627)
    at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:515)
    at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3289)
    at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(OAJboViewObjectImpl.java:1207)
    at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4146)
    at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:567)
    at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:531)
    at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2343)
    at oracle.jbo.server.ViewRowSetIteratorImpl.first(ViewRowSetIteratorImpl.java:1224)
    at oracle.jbo.server.ViewRowSetImpl.first(ViewRowSetImpl.java:2347)
    at oracle.jbo.server.ViewObjectImpl.first(ViewObjectImpl.java:5167)
    at xxaam.oracle.apps.pos.quotstg.webui.AddSupplierCO.processFormRequest(AddSupplierCO.java:185)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:734)
    at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:352)
    at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:943)
    at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1546)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:929)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:895)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:751)
    at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:352)
    at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:373)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:929)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:895)
    at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:751)
    at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:352)
    at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:340)
    at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2392)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1512)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:463)
    at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:384)
    at OA.jspService(OA.jsp:40)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
    at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
    at java.lang.Thread.run(Thread.java:534)
    and also inside button , i am handling this code.
    below code SupplierSearchVO1 contains above error query
    if (pageContext.getParameter("AddSupplierstoStrategy")!= null)
    OAViewObject vo = (OAViewObject)am.findViewObject("SupplierSearchVO1");
    int quoteCount =0;
    for(SupplierSearchVORowImpl row = (SupplierSearchVORowImpl)vo.first();row!=null;row=(SupplierSearchVORowImpl)vo.next())
    if(row.getAttribute("Select")!=null && row.getAttribute("Select").equals("Y"))
    String VendorId=row.getAttribute("VendorId").toString();
    System.out.println("VendorId"+VendorId);
    String VendorName = row.getAttribute("VendorName").toString();
    System.out.println("VendorName"+VendorName);
    String VendorSiteCode = row.getAttribute("VendorSiteCode").toString();
    System.out.println("VendorSiteCode"+VendorSiteCode);
    String City = row.getAttribute("City").toString();
    System.out.println("City"+City);
    String Country = row.getAttribute("Country").toString();
    System.out.println("Country"+Country);
    String Status = row.getAttribute("Status").toString();
    System.out.println("Status"+Status);
    DATE StatusUpdateDate =(DATE)row.getAttribute("StatusUpdateDate");
    String stringStatusUpdateDate =StatusUpdateDate.toString();
    System.out.println("print"+stringStatusUpdateDate);
    long date=new SimpleDateFormat("yyyy-MM-dd").parse(stringStatusUpdateDate,new ParsePosition(0)).getTime();
    java.sql.Date dbDate=new java.sql.Date(date);
    String ProgId1 = pageContext.getParameter("ProgId");
    System.out.println("ProgId"+ProgId1);
    OADBTransaction txn =am.getOADBTransaction();
    CallableStatement cs = txn.createCallableStatement("begin do_insert(?,?,?,?,?);end;",5);
    System.out.println("procedure is:"+cs);
    try
    cs.setString(1,VendorId);
    cs.setString(2,VendorSiteCode);
    cs.setString(3,Status);
    cs.setDate(4,dbDate);
    cs.setString(5,ProgId1);
    cs.executeUpdate();
    cs.close();
    txn.commit();
    catch(Exception e)
    //throw new OAException(e.getMessage(),OAException.ERROR);
    throw new OAException("POS","MODPOS_SUPPLIER_EXIST");
    i hope you clear every thing .please help me out..urgent
    Make sure that if no rows are selected either nothing happens or an appropriate message is shown to the user.can you give some example code snippet to add throw appropiate message if user is not selected any row.
    Thanks
    vamshi

  • How to validate XML against XSD and parse/save in one step using SAXParser?

    How to validate XML against XSD and parse/save in one step using SAXParser?
    I currently have an XML file and XSD. The XML file specifies the location of the XSD. In Java code I create a SAXParser with parameters indicating that it needs to validate the XML. However, SAXParser.parse does not validate the XML, but it does call my handler functions which save the elements/attributes in memory as it is read. On the other hand, XMLReader.parse does validate the XML against the XSD, but does not save the document in memory.
    My code can call XMLReader.parse to validate the XML followed by SAXParser.parse to save the XML document in memory. But this sound inefficient. Besides, while a valid document is being parsed by XMLReader, it can be changed to be invalid and saved, and XMLReader.parse would be looking at the original file and would think that the file is OK, and then SAXParser.parse would parse the document without errors.
    <Book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="book.xsd" name="MyBook">
      <Chapter name="First Chapter"/>
      <Chapter name="Second Chapter">
        <Section number="1"/>
        <Section number="2"/>
      </Chapter>
    </Book>
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Book">
    <xs:complexType>
      <xs:sequence>
       <xs:element name="Chapter" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
         <xs:sequence>
          <xs:element name="Section" minOccurs="0" maxOccurs="unbounded">
           <xs:complexType>
            <xs:attribute name="xnumber"/>
          </xs:complexType>
          </xs:element>
         </xs:sequence>
         <xs:attribute name="name"/>
        </xs:complexType>
       </xs:element>
      </xs:sequence>
      <xs:attribute name="name"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    public class SAXXMLParserTest
       public static void main(String[] args)
          try
             SAXParserFactory factory = SAXParserFactory.newInstance();
             factory.setNamespaceAware(true);
             factory.setValidating(true);
             SAXParser parser = factory.newSAXParser();
             parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                                "http://www.w3.org/2001/XMLSchema");
             BookHandler handler = new BookHandler();
             XMLReader reader = parser.getXMLReader();
             reader.setErrorHandler(handler);
             parser.parse("xmltest.dat", handler); // does not throw validation error
             Book book = handler.getBook();
             System.out.println(book);
             reader.parse("xmltest.dat"); // throws validation error because of 'xnumber' in the XSD
    public class Book extends Element
       private String name;
       private List<Chapter> chapters = new ArrayList<Chapter>();
       public Book(String name)
          this.name = name;
       public void addChapter(Chapter chapter)
          chapters.add(chapter);
       public String toString()
          StringBuilder builder = new StringBuilder();
          builder.append("<Book name=\"").append(name).append("\">\n");
          for (Chapter chapter: chapters)
             builder.append(chapter.toString());
          builder.append("</Book>\n");
          return builder.toString();
       public static class BookHandler extends DefaultHandler
          private Stack<Element> root = null;
          private Book book = null;
          public void startDocument()
             root = new Stack<Element>();
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
             if (qName.equals("Book"))
                String name = attributes.getValue("name");
                root.push(new Book(name));
             else if (qName.equals("Chapter"))
                String name = attributes.getValue("name");
                Chapter child = new Chapter(name);
                ((Book)root.peek()).addChapter(child);
                root.push(child);
             else if (qName.equals("Section"))
                Integer number = Integer.parseInt(attributes.getValue("number"));
                Section child = new Section(number);
                ((Chapter)root.peek()).addSection(child);
                root.push(child);
          public void endElement(String uri, String localName, String qName) throws SAXException
             Element finished = root.pop();
             if (root.size() == 0)
                book = (Book) finished;
          public Book getBook()
             return book;
          public void error(SAXParseException e)
             System.out.println(e.getMessage());
          public void fatalError(SAXParseException e)
             error(e);
          public void warning(SAXParseException e)
             error(e);
    public class Chapter extends Element
       public static class Section extends Element
          private Integer number;
          public Section(Integer number)
             this.number = number;
          public String toString()
             StringBuilder builder = new StringBuilder();
             builder.append("<Section number=\"").append(number).append("\"/>\n");
             return builder.toString();
       private String name;
       private List<Section> sections = null;
       public Chapter(String name)
          this.name = name;
       public void addSection(Section section)
          if (sections == null)
             sections = new ArrayList<Section>();
          sections.add(section);
       public String toString()
          StringBuilder builder = new StringBuilder();
          builder.append("<Chapter name=\"").append(name).append("\">\n");
          if (sections != null)
             for (Section section: sections)
                builder.append(section.toString());
          builder.append("</Chapter>\n");
          return builder.toString();
    }Edited by: sn72 on Oct 28, 2008 1:16 PM

    Have you looked at the XML DB FAQ thread (second post) in this forum? It has some examples for validating XML against schemas.

  • How to validate numbers in char field.

    Hello all,
    I have one database column with char data type. This field should allow insert only
    numbers [ zero to nine] and plus symbol .. how to validate this?
    Pls help me..
    I.m using oracle 9i database. So it does not allow REG-EXP and WITH methods.. So give some
    sql coding to do this

    As this forum is for issues with the SQL Developer tool, you'll probably get more answers in the SQL And PL/SQL forum.
    Regards,
    K.

  • How can I get an unsigned char string with nulls from a dll into LabVIEW 6i?

    The following ethernet packet data is contained in an unsigned char * string returned from my dll (it's formatted on printing):
    Received A 230 Packet On Adapter 0x008F0070
    Ethernet Dest: 01.E0.BB.00.00.15 Src: 00.E0.BB.00.DD.CC Type: 0x8868
    000000: 01 E0 BB 00 00 15 00 E0 : BB 00 DD CC 88 68 48 41 .............hHA
    000010: 00 E0 BB 00 DD CC 80 B3 : 00 00 FF FF 00 02 00 01 ................
    000020: 01 00 F0 18 FF 7F 7F FF : FF 7F 7F FF FF 7F 7F FF ................etc., etc.
    However, when I read this string into LabVIEW 6i, I only get the following:
    01E0 BB
    Which is the data before the first NULL or 00 information. I found a "Remove Unprintable Chars.vi" but it
    just sees more data before the above string, nothing after, as seen here: 5C30 31E0 BB.
    Anybody have any suggestions for how to get the rest of the string? Is there something I can do to further reformat my dll? The dll I'm using is already a wrapper around another dll so I have some flexibility, but the bottom line is, the data I want is in the format of an unsigned char *.

    Excellent advice, this mostly works so I have some further questions:
    I am just reading network traffic off my ethernet card right now, but here is what I get using my C program to test:
    000000: 01 E0 BB 00 00 15 00 E0 : BB 00 DD CC 88 68 48 41 .............hHA
    000010: 00 E0 BB 00 DD CC 80 B3 : 00 00 FF FF 00 02 00 01 ................
    000020: 01 00 38 3C FF 7F 7F 7F : 7F 7F 7F FF FF 7F 7F FF ..8<............
    000030: FF 7F 7F FF FF 7F 7F FF : 7F 7F 7F FF FF FF FF FE ................
    000040: FE FF FF FF FF 7F 7F 7F : 7F 7E 7E 7F 7F 7E 7E FF .........~~..~~.
    000050: 7F 7F 7F 7F FF 7F 7F 7F : 7F 7F 7F FF FF 7F 7E 7F ..............~.
    000060: 7F 7F 7E 7F 7F 7E 7F FF : FF 7F FF FF FE FF FF FE ..~..~..........
    000070: FF FF FF FF FF 7F 7F FF : FF 7F 7F FF FF FF FF FF ................
    000080: FF 7F 7F FF FF 7F 7F FF : FF 7F 7F FF FF 7F 7F FF ................
    000090: FF 7F 7F 7F FF 7F 7F 7F : 7F 7F 7F FF FF 7F 7F FF ................
    0000A0: FF 7F 7F 7F 7F 7E 7E 7F : 7F 7F FF FF FF FF FF FF .....~~.........
    0000B0: FF FF 7F FF FF 7F 7F FF : 7F 7F 7F FF FF 7E 7F FF .............~..
    0000C0: FF FF 7F FF FF 7F 7F FF : 7F 7F 7F FF FF 7F 7F FF ................
    0000D0: FF 7F 7F FF FF 7F 7F 7F : 7F 7F 7F FF FF FF FF FE ................
    0000E0: FE FF FF FF 00 01 : ................
    And here is what I get using LabVIEW to call the dll:
    0015 00E0 BB00 DDCC 8868 4841 00E0 BB00 DDCC 80B3 0000 FFFF 0002 0001 0100 9600 7F7F 7F7E 7F7F 7F7F 7F7F 7F7F 7F7F 7F00 B405 4300 3300 0000 0000 0000 01E0 BB00 0015 00E0 BB00 DDCC 8868 4841 00E0 BB00 DDCC 80B3 0000 FFFF 0002 0001 0100 9600 7F7F 7F7E 7F7F 7F7F 7F7F 7F7F 7F7F 7F00 F405 1B04 0C04 0000 0000 0000 8000 0000 0000 0000 0800 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
    The first thing I notice is that the first 4 bytes are chopped off, and after about 50 bytes, the data is corrupted until the sequence starts to repeat, but this time it starts with the missing 4 bytes and still corrupts after about 55 bytes.
    I am expecting the data in LabVIEW to look very similar to the C data because the network packets I am grabbing are pretty consistant, only a couple bytes will vary between them, not the number I am seeing in LabVIEW.
    Another side effect I'm seeing is that I can only run my labVIEW code once, if I try running it again it crashes with failures such as:
    memory could not be "read"
    For reference, I am opening and closing the network adapter inside the read function of my dll, but the pointer seems like it should be intact...
    Attachments:
    zListAdapters.vi ‏30 KB
    listAdapters.dll ‏201 KB
    Reading.dll ‏213 KB

Maybe you are looking for

  • How do I stream a DVD from my powerbook to my apple TV

    I'm trying to play a DVD on my macbook and stream it to my TV thru apple TV and can't get it to play.

  • Is it possible to propose another default file name in ALV Excel Export?

    Hello All, I have a problem while exporting to Excel from the WD ALV. The whole process works fine, the problem occurs when the user wants to open (without saving) multiple exported Excel documents at the same time. In this case he gets an error mess

  • Rules are disabled after disabling/enabling account.

    Hi, I have an applescript that enables or disables my work account depending on whether or not I have a VPN connection. My problem occurs when: 1. The work account is disabled 2. Mail is restarted 3. The work account is enabled again At this point al

  • Help with Straight Talk on old Verizon Iphone 4S Data Apn

    So I have had an old Iphone 4s that once worked on Verizon but I had been using it for over a year as just an IPOD basically with a GPS for Golf app and Music etc.  I saw posts about this bring your phone to Walmart and go onto Straight Talk for $45

  • DoScript tries to launch ESTK

    I'm trying to call one javascript from inside another. The child script simply displays a dialog with a listbox. The calling script creates a global variable containing an array, then uses doScript to display the array in the listbox.  Both scripts a