Esempio n. 1
0
  static {
    w2 = new DecimalFormat();
    w2.setMaximumFractionDigits(2);
    w2.setGroupingUsed(false);

    w3 = new DecimalFormat();
    w3.setMaximumFractionDigits(3);
    w3.setGroupingUsed(false);
  }
Esempio n. 2
0
  static String formatDate(Date d) {
    Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    StringBuffer sb = new StringBuffer();
    NumberFormat w4 = new DecimalFormat();
    w4.setMinimumIntegerDigits(4);
    w4.setGroupingUsed(false);
    NumberFormat w2 = new DecimalFormat();
    w2.setMinimumIntegerDigits(2);

    c.setTime(d);
    sb.append(w4.format(c.get(c.YEAR)));
    sb.append(w2.format(c.get(c.MONTH) + 1));
    sb.append(w2.format(c.get(c.DAY_OF_MONTH)));
    sb.append(w2.format(c.get(c.HOUR_OF_DAY)));
    sb.append(w2.format(c.get(c.MINUTE)));
    sb.append(w2.format(c.get(c.SECOND)));
    return sb.toString();
  }