Example #1
0
  public static void thisMonthDateForRegisterStatistic(
      int year, int month, List<StatisticCustomer> registerCustomers) {
    Calendar c = Calendar.getInstance(Locale.CHINA);
    c.set(Calendar.DAY_OF_MONTH, 1); // set date
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, month - 1);
    int maxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);

    StatisticCustomer statistic = null;
    for (int i = 0; i < maxDay; i++) {
      statistic = new StatisticCustomer();
      c.set(Calendar.DAY_OF_MONTH, i + 1);
      statistic.setRegisterDate(c.getTime());
      statistic.setRegisterCount(0);
      registerCustomers.add(statistic);
    }
  }
Example #2
0
  /**
   * Methods from Calendar BEGIN
   *
   * @param registerCustomers
   */
  public static void thisWeekDateForRegisterStatistic(List<StatisticCustomer> registerCustomers) {
    Calendar cal = Calendar.getInstance(Locale.CHINA);
    cal.setFirstDayOfWeek(Calendar.MONDAY); // Monday as first day

    StatisticCustomer statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Mon. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);

    statistic = null;
    statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Tues. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);

    statistic = null;
    statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Wed. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);

    statistic = null;
    statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Thur. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);

    statistic = null;
    statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Fri. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);

    statistic = null;
    statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Sat. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);

    statistic = null;
    statistic = new StatisticCustomer();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    statistic.setRegisterDate(cal.getTime());
    statistic.setRegisterWeekDate_str(
        "Sun. " + TMUtils.dateFormatYYYYMMDD(statistic.getRegisterDate()));
    statistic.setRegisterCount(0);
    registerCustomers.add(statistic);
  }