Ejemplo n.º 1
0
 public static String getYesterday() throws Exception {
   String strYesterday = "";
   Calendar cale = null;
   try {
     //               cale = CMCodeManager.getCalendar("KEY_D1_1_1");
     cale = new GregorianCalendar();
   } catch (Exception ex) {
     throw new Exception(ex.getMessage());
   }
   cale.add(Calendar.DATE, -1);
   strYesterday = BusinessDate.getStrByCalendar(cale);
   return strYesterday;
 }
Ejemplo n.º 2
0
  public static String[] getDateBound() throws Exception {

    String[] retarray = new String[2];
    String datetime = CMCodeManager.getString("KEY_dt_1_1");
    String[] array = datetime.split(":");
    Calendar caletoday = null;
    Calendar calenow = null;
    Calendar caleyest = null;
    Calendar caletomm = null;

    try {
      calenow = new GregorianCalendar();
      caletoday = (Calendar) calenow.clone();
    } catch (Exception ex) {
      throw new Exception(ex.getMessage());
    }
    try {

      caletoday.set(
          Integer.parseInt(BusinessDate.getStrByCalendar(calenow).substring(0, 4)),
          Integer.parseInt(BusinessDate.getStrByCalendar(calenow).substring(5, 7)) - 1,
          Integer.parseInt(BusinessDate.getStrByCalendar(calenow).substring(8, 10)),
          Integer.parseInt(array[0]),
          Integer.parseInt(array[1]),
          0);
    } catch (Exception e) {
      e.printStackTrace();
    }

    caleyest = (Calendar) caletoday.clone();

    caletomm = (Calendar) caletoday.clone();

    caleyest.add(Calendar.DATE, -1);
    caletomm.add(Calendar.DATE, 1);

    if (calenow.before(caletoday) && calenow.after(caleyest)) {
      retarray[0] =
          BusinessDate.getStrByCalendar(caleyest)
              + " "
              + CMCodeManager.getString("KEY_dt_1_1")
              + ":00";
      retarray[1] =
          BusinessDate.getStrByCalendar(caletoday)
              + " "
              + CMCodeManager.getString("KEY_dt_1_1")
              + ":00";
    } else if (calenow.after(caletoday) && calenow.before(caletomm)) {

      retarray[0] =
          BusinessDate.getStrByCalendar(caletoday)
              + " "
              + CMCodeManager.getString("KEY_dt_1_1")
              + ":00";
      retarray[1] =
          BusinessDate.getStrByCalendar(caletomm)
              + " "
              + CMCodeManager.getString("KEY_dt_1_1")
              + ":00";
    }

    return retarray;
  }