文字列型をフォーマットする。
@param formatPattern フォーマットの書式。
@param value フォーマット対象の値。
@return フォーマットした結果。
776394
public CellFormatResult format(final String formatPattern, final String value) {
        return format(formatPattern, value, Locale.getDefault());
    }
857403
def pack_and_write( self, format, value ):
        
        pattern = "%s%s" % ( self.endian_code, format )
        return self.file.write( struct.pack( pattern, value ) )
950408
public static String formatDate(final Date value, final String pattern)
    {
        return new SimpleDateFormat(pattern, currentLocale()).format(value);
    }
598421
@Override
    public final void applyPattern(String pattern)
    {

        if (hasRegistry())
        {
            super.applyPattern(pattern);
            toPattern = super.toPattern();
            return;
        }

        ArrayList<Format> foundFormats = new ArrayList<Format>();
        ArrayList<String> foundDescriptions = new ArrayList<String>();
        StringBuilder stripCustom = new StringBuilder(pattern.length());

        ParsePosition pos = new ParsePosition(0);
        char[] c = pattern.toCharArray();
        int fmtCount = 0;

        while (pos.getIndex() < pattern.length())
        {

            char charType = c[pos.getIndex()];

            if (QUOTE == charType)
            {

                appendQuotedString(pattern, pos, stripCustom, true);
                continue;

            }

            if (START_FE == charType)
            {

                fmtCount++;
                seekNonWs(pattern, pos);
                int start = pos.getIndex();
                int index = readArgumentIndex(pattern, next(pos));
                stripCustom.append(START_FE).append(index);
                seekNonWs(pattern, pos);
                Format format = null;
                String formatDescription = null;
                if (c[pos.getIndex()] == START_FMT)
                {
                    formatDescription = parseFormatDescription(pattern, next(pos));
                    format = getFormat(formatDescription);
                    if (format == null)
                    {
                        stripCustom.append(START_FMT).append(formatDescription);
                    }
                }
                foundFormats.add(format);
                foundDescriptions.add(format == null ? null : formatDescription);

                Preconditions.checkState(foundFormats.size() == fmtCount);
                Preconditions.checkState(foundDescriptions.size() == fmtCount);

                if (c[pos.getIndex()] != END_FE)
                {
                    throw new IllegalArgumentException("Unreadable format element at position " + start);
                }

            }

            //$FALL-THROUGH$
            stripCustom.append(c[pos.getIndex()]);
            next(pos);

        }

        super.applyPattern(stripCustom.toString());

        toPattern = insertFormats(super.toPattern(), foundDescriptions);

        if (containsElements(foundFormats))
        {
            Format[] origFormats = getFormats();
            // only loop over what we know we have, as MessageFormat on Java 1.3
            // seems to provide an extra format element:
            Iterator<Format> it = foundFormats.iterator();
            for (int i = 0; it.hasNext(); i++)
            {
                Format f = it.next();
                if (f != null)
                {
                    origFormats[i] = f;
                }
            }
            super.setFormats(origFormats);
        }

    }
1232693
private void parsePattern(String pattern){

		int currentIndex = 0;
		int patternLength = pattern.length();
		Vector<FormatCommandInterface> converterVector = new Vector<FormatCommandInterface>(20);

		while (currentIndex < patternLength) {
			char currentChar = pattern.charAt(currentIndex);

			if (currentChar == '%') {

				currentIndex++;
				currentChar = pattern.charAt(currentIndex);

				switch (currentChar) {
					case CLIENT_ID_CONVERSION_CHAR:
						converterVector.addElement(new ClientIdFormatCommand());
						break;
					case CATEGORY_CONVERSION_CHAR:
						CategoryFormatCommand categoryFormatCommand = new CategoryFormatCommand();
						String specifier = extraxtSpecifier(pattern, currentIndex);
						int specifierLength = specifier.length();
						if (specifierLength > 0) {
							categoryFormatCommand.init(specifier);
							currentIndex = currentIndex + specifierLength + 2;
						}
						converterVector.addElement(categoryFormatCommand);
						break;
					case DATE_CONVERSION_CHAR:
						DateFormatCommand formatCommand = new DateFormatCommand();
						specifier = extraxtSpecifier(pattern, currentIndex);
						specifierLength = specifier.length();
						if (specifierLength > 0) {
							formatCommand.init(specifier);
							currentIndex = currentIndex + specifierLength + 2;
						}
						converterVector.addElement(formatCommand);
						break;
					case MESSAGE_CONVERSION_CHAR:
						converterVector.addElement(new MessageFormatCommand());
						break;

					case PRIORITY_CONVERSION_CHAR:
						converterVector.addElement(new PriorityFormatCommand());
						break;

					case RELATIVE_TIME_CONVERSION_CHAR:
						converterVector.addElement(new TimeFormatCommand());
						break;

					case THREAD_CONVERSION_CHAR:
						converterVector.addElement(new ThreadFormatCommand());
						break;

					case THROWABLE_CONVERSION_CHAR:
						converterVector.addElement(new ThrowableFormatCommand());
						break;

					case PERCENT_CONVERSION_CHAR:
						NoFormatCommand noFormatCommand = new NoFormatCommand();
						noFormatCommand.init("%");
						converterVector.addElement(noFormatCommand);
						break;

					default:
						Log.e(TAG, "Unrecognized conversion character " + currentChar);
						break;
				}

				currentIndex++;

			} else {

				int percentIndex = pattern.indexOf("%", currentIndex);
				String noFormatString = "";
				if (percentIndex != -1) {
					noFormatString = pattern.substring(currentIndex, percentIndex);
				} else {
					noFormatString = pattern.substring(currentIndex, patternLength);
				}

				NoFormatCommand noFormatCommand = new NoFormatCommand();
				noFormatCommand.init(noFormatString);
				converterVector.addElement(noFormatCommand);

				currentIndex = currentIndex + noFormatString.length();
			}

		}

		commandArray = new FormatCommandInterface[converterVector.size()];
		converterVector.copyInto(commandArray);

		patternParsed = true;
	}
455410
public static String formatCellContent(String value, int numFmtIndex, String numFmtString) {
		if (null != numFmtString) {
			try {
				value = new DataFormatter().formatRawCellContents(Double.parseDouble(value), numFmtIndex, numFmtString);
			} catch (NumberFormatException e) {
				// ignore
			}
		}
		return value;
	}
161729
public static Format getNumberFormatter(final String pattern) {
		Format format = JKFormatUtil.formatMap.get(pattern);
		if (format == null) {
			format = new DecimalFormat(pattern);
			JKFormatUtil.formatMap.put(pattern, format);
		}
		return format;
	}
50792
public static String format(final String value, String... params) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        Pattern p = Pattern.compile("\\{(\\w+)}");
        Matcher m = p.matcher(value);
        String result = value;
        while (m.find()) {
            int paramNumber = Integer.parseInt(m.group(1));
            if (params == null || paramNumber >= params.length) {
                throw new IllegalArgumentException("params does not have value for " + m.group());
            }
            result = result.replace(m.group(), params[paramNumber]);
        }
        return result;
    }
287640
public static String toJavaDatePattern(String format) {

        int          len = format.length();
        char         ch;
        StringBuffer sb        = new StringBuffer(len);
        Tokenizer    tokenizer = new Tokenizer();

        for (int i = 0; i <= len; i++) {
            ch = (i == len) ? e
                            : format.charAt(i);

            if (!tokenizer.next(ch, dateTokens)) {
                int index = tokenizer.getLastMatch();

                if (index >= 0) {
                    sb.setLength(sb.length() - tokenizer.length());
                    sb.append(javaDateTokens[index]);
                }

                tokenizer.reset();

                if (tokenizer.isConsumed()) {
                    continue;
                }
            }

            sb.append(ch);
        }

        sb.setLength(sb.length() - 1);

        String javaPattern = sb.toString();

        return javaPattern;
    }
1248339
public static String formatDate(long value) {
        synchronized (HttpDateFormat.class) {
            Date dateValue = new Date(value);
            return FORMAT.format(dateValue);
        }
    }
824247
@Transformer(requireTemplate = true)
    public static String format(Number number, String pattern, Locale locale) {
        return format(null, number, pattern, locale);
    }
271618
public static Pattern wellFormedToPattern(String value) {
        StringBuilder sb = new StringBuilder(value.length() + 4);
        for (int x = 0; x < value.length(); x++) {
            if (value.charAt(x) == '*') {
                sb.append(".*");
            } else if (value.charAt(x) == '?') {
                sb.append(".");
            } else if (value.charAt(x) == '\\' && (x + 1) < value.length()) {
                sb.append('\\').append(value.charAt(x++)).append('\\').append(value.charAt(x));
            } else if ((value.charAt(x) >= 'a' && value.charAt(x) <= 'z')
                    || (value.charAt(x) >= 'A' && value.charAt(x) <= 'Z')
                    || (value.charAt(x) >= '0' && value.charAt(x) <= '9')) {
                sb.append(value.charAt(x));
            } else {
                sb.append('\\').append(value.charAt(x));
            }
        }
        return Pattern.compile(sb.toString());
    }
225888
public CellFormatResult format(final String formatPattern, final Date value, final Locale locale) {
        return format(new DateCell(value, formatPattern), locale);
    }
745302
public <N extends Number> CellFormatResult format(final String formatPattern, final N value) {
        return format(formatPattern, value, Locale.getDefault());
    }
186578
public static String format(final Date date, final String pattern) {
        return format(date, pattern, null, null);
    }
809339
@Override
    public Object format(Object value) {
        if (value == null) {
            return nullStringValue;
        }
        if(value.getClass().isArray()) {
            return asList(value);
        } else if (value instanceof Date) {
           Date date = (Date) value;
           if (date.getTime() % ONE_DAY_IN_MILLIS == 0) {
               return new SimpleDateFormat(datePattern).format(date);
           } else {
               return new SimpleDateFormat(dateTimePattern).format(date);
           }
        } else if(value instanceof CompositeData) {
            return toMap((CompositeData)value);
        } else if(value instanceof Element) {
            return parseXmlElement((Element) value);
        }
        
        return value;
    }
673669
public CellFormatResult format(final String formatPattern, final String value, final Locale locale) {
        return format(new TextCell(value, formatPattern), locale);
    }