예제 #1
0
  public static String getDateAsDDMMYYYYWithTimestamp(Date inputDate) {
    if (GenericUtils.isNotNull(inputDate)) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(inputDate);
      String day = new Integer(cal.get(Calendar.DATE)).toString();
      String mm = new Integer(cal.get(Calendar.MONTH) + 1).toString();
      String year = new Integer(cal.get(Calendar.YEAR)).toString();
      String hours = new Integer(cal.get(Calendar.HOUR_OF_DAY)).toString();
      String minutes = new Integer(cal.get(Calendar.MINUTE)).toString();
      String seconds = new Integer(cal.get(Calendar.SECOND)).toString();

      return StringUtils.leftPad(day, 2, "0")
          + DateUtils.DATE_SEPARATOR_CHAR
          + StringUtils.leftPad(mm, 2, "0")
          + DateUtils.DATE_SEPARATOR_CHAR
          + year
          + PortalConstant.SINGLE_SPACE
          + StringUtils.leftPad(hours, 2, "0")
          + PortalConstant.COLON
          + StringUtils.leftPad(minutes, 2, "0")
          + PortalConstant.COLON
          + StringUtils.leftPad(seconds, 2, "0");
    }

    return PortalConstant.BLANK_STRING;
  }
예제 #2
0
 /** @param daoClass */
 public DAOMetaData(Class<?> daoClass, DAOConfig config) {
   this.daoClass = daoClass;
   this.constants =
       Collections.unmodifiableMap( //
           GenericUtils.getConstantFrom(daoClass, true, true));
   this.config = config;
   this.attributes = new ConcurrentHashMap<String, Object>(4);
 }
예제 #3
0
  public static String getDateAsDDMMYYYYFromMysqlDate(Date yyyymmdd) {
    if (GenericUtils.isNotNull(yyyymmdd)) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(yyyymmdd);
      String day = new Integer(cal.get(Calendar.DATE)).toString();
      String mm = new Integer(cal.get(Calendar.MONTH) + 1).toString();
      String year = new Integer(cal.get(Calendar.YEAR)).toString();
      return StringUtils.leftPad(day, 2, "0")
          + DateUtils.DATE_SEPARATOR_CHAR
          + StringUtils.leftPad(mm, 2, "0")
          + DateUtils.DATE_SEPARATOR_CHAR
          + year;
    }

    return PortalConstant.BLANK_STRING;
  }
예제 #4
0
  public static String getDateAsYYYYMMDD(Date inputDate) {
    if (GenericUtils.isNotNull(inputDate)) {
      Calendar cal = Calendar.getInstance();
      cal.setTime(inputDate);
      String day = new Integer(cal.get(Calendar.DATE)).toString();
      String mm = new Integer(cal.get(Calendar.MONTH) + 1).toString();
      String year = new Integer(cal.get(Calendar.YEAR)).toString();
      return year
          + DateUtils.DATE_SEPARATOR_CHAR
          + StringUtils.leftPad(mm, 2, "0")
          + DateUtils.DATE_SEPARATOR_CHAR
          + StringUtils.leftPad(day, 2, "0");
    }

    return PortalConstant.BLANK_STRING;
  }
예제 #5
0
  public static Date getStringAsDate(String dateAsString) {
    if (GenericUtils.isNotNullOrEmpty(dateAsString)) {
      String strTmp = dateAsString.replaceAll(DATE_SEPARATOR_CHAR, PortalConstant.COLON);
      String[] dmyArray = strTmp.split(PortalConstant.COLON);

      if (dmyArray != null && dmyArray.length == 3) {
        int day = new Integer(dmyArray[0]);
        int mm = new Integer(dmyArray[1]) - 1;
        int year = new Integer(dmyArray[2]);

        Calendar cal = Calendar.getInstance();
        cal.set(year, mm, day);

        return cal.getTime();
      }
    }

    return null;
  }
예제 #6
0
  public static String getDateAsDDMMYYYYFromMysqlDate(String yyyymmdd) {
    if (GenericUtils.isNotNullOrEmpty(yyyymmdd)) {
      String strTmp = yyyymmdd.replaceAll(DATE_SEPARATOR_CHAR, PortalConstant.COLON);
      String[] ymdArray = strTmp.split(PortalConstant.COLON);

      if (ymdArray != null && ymdArray.length == 3) {
        int day = new Integer(ymdArray[2]);
        int mm = new Integer(ymdArray[1]) - 1;
        int year = new Integer(ymdArray[0]);

        Calendar cal = Calendar.getInstance();
        cal.set(year, mm, day);

        return getDateAsString(cal.getTime());
      }
    }

    return PortalConstant.BLANK_STRING;
  }
예제 #7
0
 /**
  * 泛型类型变量在本DAO类中真正的类型
  *
  * @param declaringClass 声明类型变量typeVarName的类
  * @param typeVarName 泛型变量名
  * @return
  */
 @SuppressWarnings("rawtypes")
 public Class resolveTypeVariable(Class<?> declaringClass, String typeVarName) {
   return GenericUtils.resolveTypeVariable(daoClass, declaringClass, typeVarName);
 }
 /**
  * Copy Demo File Name into external file
  *
  * @param name File Name inside jar file
  * @param fname File Name output file name
  * @param cfg Resource Configuration object
  * @throws IOException
  */
 public static void copyDemoFileToFile(String name, String fname, ITestResourceConfig cfg)
     throws IOException {
   GenericUtils.copyToFile(readDemoFileAsStream(name, cfg), fname);
 }