Example #1
0
 public static void main(String[] args) {
   try {
     String[] stra = BusinessDate.getDateBound();
     System.out.println("array[0]:" + stra[0] + "\narray[1]:" + stra[1]);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Example #2
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;
 }
Example #3
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;
  }
Example #4
0
 public static String getDay() {
   return BusinessDate.getNowDay().substring(8, 10);
 }
Example #5
0
 public static String getMonth() {
   return BusinessDate.getNowDay().substring(5, 7);
 }
Example #6
0
 public static String getYear() {
   //          return CMCodeManager.getString("KEY_D1_1_1").substring(0,4);
   return BusinessDate.getNowDay().substring(0, 4);
 }