Ejemplo n.º 1
0
  public static Map<String, Object> assembleCrmsfaGenericFormMergeContext(
      TimeZone timeZone, Locale locale) {
    Map<String, Object> templateContext = new HashMap<String, Object>();

    Calendar now = Calendar.getInstance(timeZone, locale);
    String mmddyyyy = new java.text.SimpleDateFormat("MM/dd/yyyy").format(now.getTime());
    String mmddyyyy2 = new java.text.SimpleDateFormat("MM-dd-yyyy").format(now.getTime());
    String yyyymmdd = new java.text.SimpleDateFormat("yyyy/MM/dd").format(now.getTime());
    String yyyymmdd2 = new java.text.SimpleDateFormat("yyyy-MM-dd").format(now.getTime());
    Integer month = Integer.valueOf(now.get(Calendar.MONTH));
    month++;
    String monthStr = month.toString();
    if (monthStr.length() == 1) {
      monthStr = "0" + monthStr;
    }
    // TODO: oandreyev. Test this code more carefully.
    ArrayList<String> monthNames = (ArrayList<String>) UtilDateTime.getMonthNames(locale);
    String monthName = monthNames.get(month - 1);
    // String monthLabel = null;
    // if (month == 1) {
    //    monthLabel = "CommonJanuary";
    // } else if (month == 2) {
    //    monthLabel = "CommonFebruary";
    // } else if (month == 3) {
    //    monthLabel = "CommonMarch";
    // } else if (month == 4) {
    //    monthLabel = "CommonApril";
    // } else if (month == 5) {
    //    monthLabel = "CommonMay";
    // } else if (month == 6) {
    //    monthLabel = "CommonJune";
    // } else if (month == 7) {
    //    monthLabel = "CommonJuly";
    // } else if (month == 8) {
    //    monthLabel = "CommonAugust";
    // } else if (month == 9) {
    //    monthLabel = "CommonSeptember";
    // } else if (month == 10) {
    //    monthLabel = "CommonOctober";
    // } else if (month == 11) {
    //    monthLabel = "CommonNovember";
    // } else if (month == 12) {
    //    monthLabel = "CommonDecember";
    // }
    // if (UtilValidate.isNotEmpty(monthLabel)) {
    //    monthName = UtilProperties.getMessage("CommonUiLabels", monthLabel, locale);
    // }

    templateContext.put("mmddyyyy", mmddyyyy);
    templateContext.put("mmddyyyy2", mmddyyyy2);
    templateContext.put("yyyymmdd", yyyymmdd);
    templateContext.put("yyyymmdd2", yyyymmdd2);
    templateContext.put("month", monthStr);
    templateContext.put("monthName", monthName);
    templateContext.put("day", new Integer(now.get(Calendar.DAY_OF_MONTH)).toString());
    templateContext.put("year", new Integer(now.get(Calendar.YEAR)).toString());

    return templateContext;
  }