Package com.meidusa.amoeba.sqljep

Examples of com.meidusa.amoeba.sqljep.ParseException


      return null;
    }
    try {
      if (param1 instanceof java.util.Date && param2 instanceof java.util.Date) {
        if (param1 instanceof Time || param2 instanceof Time) {
          throw new ParseException();
        }
        java.util.Date d1 = (java.util.Date)param1;
        java.util.Date d2 = (java.util.Date)param2;
        cal.setTimeInMillis(d1.getTime());
        int y1 = cal.get(YEAR);
        int m1 = cal.get(MONTH);
        int dt1 = cal.get(DATE);
        cal.setTimeInMillis(d2.getTime());
        int y2 = cal.get(YEAR);
        int m2 = cal.get(MONTH);
        int dt2 = cal.get(DATE);
        BigDecimal m = new BigDecimal((y1-y2)*12+(m1-m2));
        BigDecimal d = new BigDecimal(dt1-dt2);
        d = d.divide(DAYS_IN_MONTH, 40, BigDecimal.ROUND_HALF_UP);
        return m.add(d);
      } else {
        throw new ParseException();
      }
    } catch (ParseException e) {
      throw new ParseException(WRONG_TYPE+"  month_between("+param1.getClass()+","+param2.getClass()+")");
    }
  }
View Full Code Here


      }
      else if (param1 instanceof java.sql.Date) {
        java.sql.Date d = (java.sql.Date)param1;
        return new java.sql.Date(d.getTime()+days*86400000);
      } else {
        throw new ParseException();
      }
    } catch (ParseException e) {
      throw new ParseException(WRONG_TYPE+"  addDate("+param1.getClass()+","+param2.getClass()+")");
    }
  }
View Full Code Here

        java.util.Date d = (java.util.Date)param1;
        cal.setTimeInMillis(d.getTime());
        cal.add(Calendar.MONTH, months);
        return new java.util.Date(cal.getTimeInMillis());
      } else {
        throw new ParseException();
      }
    } catch (ParseException e) {
      throw new ParseException(WRONG_TYPE+"  month_between("+param1.getClass()+","+param2.getClass()+")");
    }
  }
View Full Code Here

    if (param instanceof Timestamp || param instanceof java.sql.Date) {
      java.util.Date ts = (java.util.Date)param;
      cal.setTimeInMillis(ts.getTime());
      return new Integer(cal.get(YEAR));
    }
    throw new ParseException(WRONG_TYPE+" year("+param.getClass()+")");
  }
View Full Code Here

    if (param instanceof Timestamp || param instanceof java.sql.Date) {
      java.util.Date ts = (java.util.Date)param;
      cal.setTimeInMillis(ts.getTime());
      return new Integer(cal.get(WEEK_OF_YEAR));
    }
    throw new ParseException(WRONG_TYPE+" weekofyear("+param.getClass()+")");
  }
View Full Code Here

    }
    if (param instanceof Timestamp) {
      Timestamp ts = (Timestamp)param;
      return new Long(ts.getTime());
    }
    throw new ParseException(WRONG_TYPE+" microsecond("+param.getClass()+")");
  }
View Full Code Here

      Comparable<?>  param1 = runtime.stack.pop();
      return new Comparable<?>[]{param1,param2,param3};
    } else {
      // remove all parameters from stack and push null
      removeParams(runtime.stack, num);
      throw new ParseException(PARAMS_NUMBER+" for rpad");
    }
  }
View Full Code Here

    String chars = param3.toString();
    int length;
    try {
      length = getInteger(param2);
    } catch (ParseException e) {
      throw new ParseException(PARAM_EXCEPTION);
    }
    if (length == inputStr.length()) {
      return inputStr;
    }
    else if (length < inputStr.length()) {
View Full Code Here

    if (param instanceof Timestamp || param instanceof java.sql.Date) {
      java.util.Date ts = (java.util.Date)param;
      cal.setTimeInMillis(ts.getTime());
      return new Integer(cal.get(MONTH));
    }
    throw new ParseException(WRONG_TYPE+" month("+param.getClass()+")");
  }
View Full Code Here

          dayOfWeek = FRIDAY;
        }
        else if (d == "SATURDAY") {
          dayOfWeek = SATURDAY;
        } else {
          throw new ParseException();
        }
      } else {
        throw new ParseException();
      }
      if (param1 instanceof Timestamp || param1 instanceof java.sql.Date) {
        java.util.Date d = (java.util.Date)param1;
        cal.setTimeInMillis(d.getTime());
        int day = cal.get(DAY_OF_WEEK);
        cal.add(DATE, (day<dayOfWeek) ? dayOfWeek-day : 7+dayOfWeek-day);
        return new java.util.Date(cal.getTimeInMillis());
      } else {
        throw new ParseException();
      }
    } catch (ParseException e) {
      throw new ParseException(WRONG_TYPE+"  next_day("+param1.getClass()+","+param2.getClass()+")");
    }
  }
View Full Code Here

TOP

Related Classes of com.meidusa.amoeba.sqljep.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.