Ejemplo n.º 1
0
 /** @return 01092010 */
 public static String getDateNumeric() {
   String year = getYear();
   String month = getMonth();
   String day = getDayOfMonth();
   String dn = year + month + day;
   if (mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("item.date.locale")
       == null)
     mpv5.db.objects.User.getCurrentUser()
         .getProperties()
         .changeProperty("item.date.locale", Locale.getDefault().toString());
   try {
     Locale l =
         TypeConversion.stringToLocale(
             mpv5.db.objects.User.getCurrentUser()
                 .getProperties()
                 .getProperty("item.date.locale"));
     if (l.equals(Locale.GERMAN) || l.equals(Locale.GERMANY)) {
       dn = day + month + year;
     }
   } catch (Exception e) {
     Log.Debug(e);
   } finally {
     return dn;
   }
 }
Ejemplo n.º 2
0
  /**
   * Creates a hash map view to all the object's form fields and their values, including their
   * referenced objects resolved to keys and values.<br>
   * This method is safe to never return null values.
   *
   * @param identifier or NULL
   * @return A HashMap<key,value/>
   */
  public synchronized Map<String, Object> getFormattedFormFields(final String identifier) {
    Map<String, Object> map = getFormFields();
    TreeMap<String, Object> maps = new TreeMap<String, Object>();

    for (Iterator<String> it = map.keySet().iterator(); it.hasNext(); ) {
      String key = it.next();
      Object o = map.get(key);

      String skey = null;
      if (identifier == null) {
        skey = obj.getType() + "." + key;
      } else {
        skey = identifier + "." + key;
      }

      if (o == null || String.valueOf(o).equals("null")) {
        maps.put(skey, "");
      } else if (o instanceof DatabaseObject && !(o instanceof Group)) {
        maps.putAll(
            new FormFieldsHandler((DatabaseObject) o)
                .getFormattedFormFields(obj.getType() + "." + key));
      } else if (o instanceof Boolean) {
        maps.put(skey, TypeConversion.booleanToString((Boolean) o));
      } else if (o instanceof Double || o.getClass() == double.class) {
        maps.put(skey, FormatNumber.formatDezimal((Double) o));
      } else if (o instanceof Date) {
        maps.put(skey, DateConverter.getDefDateString((Date) o));
      } else {
        maps.put(skey, o);
      }
    }
    List<String[]> mapi =
        User.getCurrentUser().getProperties().getProperties("companyinfo.").getList();
    for (int i = 0; i < mapi.size(); i++) {
      String[] strings = mapi.get(i);
      if (strings[1] != null) {
        maps.put(
            "companyinfo." + strings[0],
            strings[1].contains("[") ? VariablesHandler.parse(strings[1], obj) : strings[1]);
      }
    }

    return maps;
  }