The alternate ISO format, PyyyymmddThhmmss, which excludes weeks.
<p>
Even if weeks are present in the period, they are not output.
Fractional seconds (milliseconds) will appear if required.

@return the formatter
971493
public static PeriodFormatter alternate() {
        if (cAlternate == null) {
            cAlternate = new PeriodFormatterBuilder()
                .appendLiteral("P")
                .printZeroAlways()
                .minimumPrintedDigits(4)
                .appendYears()
                .minimumPrintedDigits(2)
                .appendMonths()
                .appendDays()
                .appendSeparatorIfFieldsAfter("T")
                .appendHours()
                .appendMinutes()
                .appendSecondsWithOptionalMillis()
                .toFormatter();
        }
        return cAlternate;
    }
1032851
public StringFormatter getFormatter() {
		if (formatter == null) {
                    ResourceBundle b = ResourceBundle.getBundle(UI_RESOURCE_BUNDLE_NAME, new UTF8Control());
			formatter = new StringFormatter(b, getLocale());
		}
		return formatter;
	}
754489
public Object getFormatFor() {

        Transformer mapFunction = new Transformer() {

            public Object transform(Object param) {

                if (m_functionBean == null) {
                    return new CmsDynamicFunctionFormatWrapper(m_cms, null);
                }
                int width = -1;
                String type = null;
                boolean isWidth = false;
                if (param instanceof Long) {
                    width = (int)((Long)param).longValue();
                    isWidth = true;
                } else if (param instanceof Integer) {
                    width = ((Integer)param).intValue();
                    isWidth = true;
                } else {
                    type = param.toString();
                }
                Format format;
                if (isWidth) {
                    format = m_functionBean.getFormatForContainer(m_cms, "", width);
                } else {
                    format = m_functionBean.getFormatForContainer(m_cms, type, -1);
                }
                CmsDynamicFunctionFormatWrapper wrapper = new CmsDynamicFunctionFormatWrapper(m_cms, format);
                return wrapper;
            }
        };
        return CmsCollectionsGenericWrapper.createLazyMap(mapFunction);
    }
1107337
public static String convertFormat(String format) {
		if (format == null)
			return null;
		else {
			// day of week
			format = format.replaceAll("EEE", "D");
			// year
			format = format.replaceAll("yy", "y");

			// month
			if (format.indexOf("MMM") != -1) {
				format = format.replaceAll("MMM", "M");
			} else {
				format = format.replaceAll("M", "m");
			}
			return format;
		}
	}
501443
public static String getUpTime() {
        long diff = ManagementFactory.getRuntimeMXBean().getUptime();
        diff /= 1000 * 60;
        long minutes = diff % 60;
        diff /= 60;
        long hours = diff % 24;
        diff /= 24;
        long days = diff;
        StringBuilder buf = new StringBuilder();
        if (days == 1) {
            buf.append("1 day ");
        } else if (days > 1) {
            buf.append(Long.valueOf(days).toString()).append(" days ");
        }
        DecimalFormat format = new DecimalFormat();
        format.setMinimumIntegerDigits(2);
        buf.append(format.format(hours)).append(":")
                .append(format.format(minutes));
        return buf.toString();
    }
983236
private String getFormattedDate(int dateTimeFormat) {

        DateFormat df;
        String result;
        if (isWholeDay()) {
            df = DateFormat.getDateInstance(dateTimeFormat, m_series.getLocale());
            result = df.format(getStart());
            if (getLastDay().after(getStart())) {
                result += DATE_SEPARATOR + df.format(getLastDay());
            }
        } else {
            df = DateFormat.getDateTimeInstance(dateTimeFormat, DateFormat.SHORT, m_series.getLocale());
            result = df.format(getStart());
            if (getEnd().after(getStart())) {
                if (isMultiDay()) {
                    result += DATE_SEPARATOR + df.format(getEnd());
                } else {
                    df = DateFormat.getTimeInstance(DateFormat.SHORT, m_series.getLocale());
                    result += DATE_SEPARATOR + df.format(getEnd());
                }
            }
        }

        return result;
    }
737118
public static String formatDuration(final long startTime, final long endTime) {
    if (startTime == -1) {
      return "-";
    }

    final long durationMS;
    if (endTime == -1) {
      durationMS = System.currentTimeMillis() - startTime;
    } else {
      durationMS = endTime - startTime;
    }

    long seconds = durationMS / 1000;
    if (seconds < 60) {
      return seconds + " sec";
    }

    long minutes = seconds / 60;
    seconds %= 60;
    if (minutes < 60) {
      return minutes + "m " + seconds + "s";
    }

    long hours = minutes / 60;
    minutes %= 60;
    if (hours < 24) {
      return hours + "h " + minutes + "m " + seconds + "s";
    }

    final long days = hours / 24;
    hours %= 24;
    return days + "d " + hours + "h " + minutes + "m";
  }
251902
Format getFormat() {
    final int ordinal;
    final Flavor f = getFlavor();
    if ((f == Flavor.HYBRID) || (f == Flavor.SPARSE)) {
      ordinal = 2 | ( mergeFlag ? 0 : 1 ); //Hybrid is serialized as SPARSE
    } else {
      ordinal = ((slidingWindow != null) ? 4 : 0)
               | (((pairTable != null) && (pairTable.getNumPairs() > 0)) ? 2 : 0)
               | ( mergeFlag ? 0 : 1 );
    }
    return Format.ordinalToFormat(ordinal);
  }
1361641
public static Duration fromMillis(long milliseconds) {
		Duration.Builder builder = builder();

		if (milliseconds < 0) {
			builder.prior(true);
			milliseconds *= -1;
		}

		int seconds = (int) (milliseconds / 1000);

		Integer weeks = seconds / (60 * 60 * 24 * 7);
		if (weeks > 0) {
			builder.weeks(weeks);
		}
		seconds %= 60 * 60 * 24 * 7;

		Integer days = seconds / (60 * 60 * 24);
		if (days > 0) {
			builder.days(days);
		}
		seconds %= 60 * 60 * 24;

		Integer hours = seconds / (60 * 60);
		if (hours > 0) {
			builder.hours(hours);
		}
		seconds %= 60 * 60;

		Integer minutes = seconds / (60);
		if (minutes > 0) {
			builder.minutes(minutes);
		}
		seconds %= 60;

		if (seconds > 0) {
			builder.seconds(seconds);
		}

		return builder.build();
	}
1269464
private Format getFormat() {

        char ch;

        while (index < format.length()) {
            if ((ch = format.charAt(index)) != '%') {
                buffer.append(ch);
                index++;
                continue;
            }

            Format fmt = new Format();

            // Process flags.
            boolean repeat = true;
            while (repeat) {

                if (index + 1 >= format.length()) throw new IllegalArgumentException("Malformed format");

                switch (ch = format.charAt(++index)) { // Skip the first '%'
                    case '-':
                        fmt.flags |= LEFT;
                        break;
                    case '+':
                        fmt.flags |= PLUS;
                        break;
                    case ' ':
                        fmt.flags |= SPACE;
                        break;
                    case '#':
                        fmt.flags |= SPECIAL;
                        break;
                    case '0':
                        fmt.flags |= ZEROPAD;
                        break;
                    case '\'':
                        fmt.flags |= GROUPING;
                        break;
                    default:
                        repeat = false;
                        break;
                }
            }

            // Get field width.
            if (Character.isDigit(ch)) {
                // Explicit number.
                fmt.fieldWidth = skipDigits();
            }

            if (index >= format.length()) throw new IllegalArgumentException("Malformed format");

            // Get precision.
            if ((ch = format.charAt(index)) == '.') {

                if (++index >= format.length()) throw new IllegalArgumentException("Malformed format");

                fmt.precision = skipDigits();
                if (fmt.precision < 0) {
                    fmt.precision = 0;
                }
            }

            if (index >= format.length()) throw new IllegalArgumentException("Malformed format");

            switch (ch = format.charAt(index++)) {
                case 'c':
                    fmt.type = CHAR;
                    return fmt;
                case 's':
                    fmt.type = STRING;
                    return fmt;
                case '%':
                    buffer.append('%');
                    continue;

                    // Octal, hexadecimal and decimal.

                case 'o':
                    fmt.type = DECIMAL;
                    fmt.base = 8;
                    return fmt;
                case 'X':
                    fmt.flags |= LARGE;
                case 'x':
                    fmt.type = DECIMAL;
                    fmt.base = 16;
                    return fmt;
                case 'd':
                case 'i':
                    fmt.type = DECIMAL;
                    return fmt;

                    // Floating point

                case 'f':
                case 'g':
                    fmt.type = FLOAT;
                    return fmt;
                case 'e':
                    fmt.type = FLOAT;
                    fmt.flags |= SCI;
                    return fmt;
                case 'E':
                    fmt.type = FLOAT;
                    fmt.flags |= SCI;
                    fmt.flags |= UPPER;
                    return fmt;
                default:
                    buffer.append('%');
                    buffer.append(ch);
                    continue;
            }
        }

        return null;
    }
987737
public static long parseDuration(String str) throws IllegalArgumentException {
        long seconds = 0;
        if (str == null)
            return 0;

        // Check for ISO_8601 format
        if (str.startsWith("P")) {
            // A common mistake is when the minutes format is intended but the month format is specified 
            // e.g. one month "P1M" is set, but on minute "PT1M" is meant.
            Duration dur;
            try {
                dur = DatatypeFactory.newInstance().newDuration(str);
                seconds = dur.getTimeInMillis(STATIC_DATE) / 1000;
            } catch (Exception ex) {
                throw new IllegalArgumentException("Cannot parse duration tag value: " + str, ex);
            }
            return seconds;
        }

        try {
            int index = str.indexOf(":");
            if (index > 0) {
                String hourStr = str.substring(0, index);
                String minStr = str.substring(index + 1);
                String secondsStr = "0";
                index = minStr.indexOf(":");
                if (index > 0) {
                    secondsStr = minStr.substring(index + 1, index + 3);
                    minStr = minStr.substring(0, index);
                }

                seconds += Integer.parseInt(hourStr) * 60L * 60;
                seconds += Integer.parseInt(minStr) * 60L;
                seconds += Integer.parseInt(secondsStr);
                return seconds;
            } else {
                // value contains minutes
                seconds = Integer.parseInt(str) * 60;
            }
        } catch (Exception ex) {
            throw new IllegalArgumentException("Cannot parse duration tag value: " + str, ex);
        }
        return seconds;
    }
602616
@Override
  public DurationFormatterFactory setPeriodFormatter(
      PeriodFormatter formatter) {
    if (formatter != this.formatter) {
      this.formatter = formatter;
      reset();
    }
    return this;
  }
485890
public static PeriodType minutes() {
        PeriodType type = cMinutes;
        if (type == null) {
            type = new PeriodType(
                "Minutes",
                new DurationFieldType[] { DurationFieldType.minutes() },
                new int[] { -1, -1, -1, -1, -1, 0, -1, -1, }
            );
            cMinutes = type;
        }
        return type;
    }
46303
public static String formatMillis(double theMillis) {
		StringBuilder buf = new StringBuilder(20);
		if (theMillis > 0.0 && theMillis < 1.0) {
			buf.append(getSubMillisecondMillisFormat().format(theMillis));
			buf.append("ms");
		} else if (theMillis < (10 * DateUtils.MILLIS_PER_SECOND)) {
			buf.append((int) theMillis);
			buf.append("ms");
		} else if (theMillis >= DateUtils.MILLIS_PER_DAY) {
			double days = theMillis / DateUtils.MILLIS_PER_DAY;
			if (days >= 10) {
				buf.append(getTenDayFormat().format(days));
				buf.append(" days");
			} else if (days != 1.0f) {
				buf.append(getDayFormat().format(days));
				buf.append(" days");
			} else {
				buf.append(getDayFormat().format(days));
				buf.append(" day");
			}
		} else {
			long millisAsLong = (long) theMillis;
			append(buf, "", 2, ((millisAsLong % DateUtils.MILLIS_PER_DAY) / DateUtils.MILLIS_PER_HOUR));
			append(buf, ":", 2, ((millisAsLong % DateUtils.MILLIS_PER_HOUR) / DateUtils.MILLIS_PER_MINUTE));
			append(buf, ":", 2, ((millisAsLong % DateUtils.MILLIS_PER_MINUTE) / DateUtils.MILLIS_PER_SECOND));
			if (theMillis <= DateUtils.MILLIS_PER_MINUTE) {
				append(buf, ".", 3, (millisAsLong % DateUtils.MILLIS_PER_SECOND));
			}
		}
		return buf.toString();
	}
709788
public static String getDatetime() {
        long currentTimeMillis = System.currentTimeMillis();
        final Date date = new Date(currentTimeMillis);
        // ISO-8061 for YAMLish diagnostic
        return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(date);
    }
569553
public ResourceFormatParser getParserForMIMEType(final String mimeType) throws UnsupportedFormatException {
        //clean up encoding
        final String cleanMime;
        if (null != mimeType && mimeType.indexOf(";") > 0) {
            cleanMime = mimeType.substring(0, mimeType.indexOf(";"));
        } else {
            cleanMime = mimeType;
        }
        if (!validMimeType(cleanMime)) {
            throw new IllegalArgumentException("Invalid MIME type: " + mimeType);
        }
        for (final ResourceFormatParser resourceFormatParser : listParsers()) {
            if(null!= resourceFormatParser.getMIMETypes()){
                if (resourceFormatParser.getMIMETypes().contains(cleanMime)) {
                    return resourceFormatParser;
                } else {
                    for (final String s : resourceFormatParser.getMIMETypes()) {
                        if (validMimeType(s) && s.startsWith("*/")) {
                            String t1 = s.substring(2);
                            String t2 = cleanMime.substring(cleanMime.indexOf("/") + 1);
                            if (t1.equals(t2)) {
                                return resourceFormatParser;
                            }
                        }
                    }
                }
            }
        }
        throw new UnsupportedFormatException("No provider available to parse MIME type: " + mimeType);
    }
82982
public static SimpleDateFormat getAlternateDateFormat() {
		if (alternateDateFormat == null) { // NOPMD
			// pour construire ce dateFormat on enlève les '/' et '.' du pattern de dateFormat
			// ie on peut saisir en France 251202 au lieu de 25/12/02 ou 25/12/2002

			final StringBuilder patternSb = new StringBuilder(getDateFormat().toPattern());
			// note : il faut réévaluer pattern.length() chaque fois dans la condition
			// puisque la longueur diminue au fur et à mesure
			for (int i = 0; i < patternSb.length(); i++) {
				if (!Character.isLetter(patternSb.charAt(i))) {
					patternSb.deleteCharAt(i);
				}
			}

			final Locale locale = Locale.getDefault();
			final String pattern = patternSb.toString();
			final String pattern2 = pattern.replaceAll("y", "");
			final String pattern3 = pattern2.replaceAll("M", "");
			final SimpleDateFormat myAlternateDateFormat2 = new SimpleDateFormat(pattern2, locale);
			final SimpleDateFormat myAlternateDateFormat3 = new SimpleDateFormat(pattern3, locale);

			// CHECKSTYLE:OFF
			final SimpleDateFormat myAlternateDateFormat = new SimpleDateFormat(pattern, locale) {
				// CHECKSTYLE:ON
				private static final long serialVersionUID = 1L;

				@Override
				public Date parse(final String text) throws ParseException {
					try {
						return super.parse(text);
					} catch (final ParseException ex) {
						final Calendar myCalendar = Calendar.getInstance();
						final int year = myCalendar.get(Calendar.YEAR);
						final int month = myCalendar.get(Calendar.MONTH);
						try {
							myCalendar.setTime(myAlternateDateFormat2.parse(text));
							myCalendar.set(Calendar.YEAR, year);
							return myCalendar.getTime();
						} catch (final ParseException ex1) {
							try {
								myCalendar.setTime(myAlternateDateFormat3.parse(text));
								myCalendar.set(Calendar.YEAR, year);
								myCalendar.set(Calendar.MONTH, month);
								return myCalendar.getTime();
							} catch (final ParseException ex2) {
								throw ex;
							}
						}
					}
				}
			};

			// on n'accepte pas le 30/02 (qui serait alors le 02/03)
			myAlternateDateFormat.setLenient(false);
			myAlternateDateFormat2.setLenient(false);
			myAlternateDateFormat3.setLenient(false);

			alternateDateFormat = myAlternateDateFormat; // NOPMD
		}

		return alternateDateFormat; // NOPMD
	}