public static String insertDate(String pattern, long time) {
        DateFormat df = new SimpleDateFormat("yyyy.MM.dd:HH:mm:ss.SSS Z", Locale.US);
        df.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date date = new Date(time);
        String datetime = df.format(date);
        StringBuilder result = new StringBuilder();
        int i=0;
        while (i < pattern.length()) {
            int j = pattern.indexOf('%',i);
            if (j == -1 || j >= pattern.length()-1) { // done
                result.append(pattern.substring(i)); // copy rest of pattern and quit
                break;
            }
            result.append(pattern.substring(i, j));
            switch (pattern.charAt(j+1)) {
            case 'Y':
                result.append(datetime.substring(0,4)); // year
                break;
            case 'm':
                result.append(datetime.substring(5,7)); // month
                break;
            case 'd':
                result.append(datetime.substring(8,10)); // day of month
                break;
            case 'H':
                result.append(datetime.substring(11,13)); // hour
                break;
            case 'M':
                result.append(datetime.substring(14,16)); // minute
                break;
            case 'S':
                result.append(datetime.substring(17,19)); // second
                break;
            case 's':
                result.append(datetime.substring(20,23)); // thousanths
                break;
            case 'Z':
                result.append(datetime.substring(24)); // time zone string
                break;
            case 'T':
                result.append(Long.toString(time)); //time in Millis
                break;
            case 'x':
                result.append(capitalize(dfMMM.format(date)));
                break;
            case '%':
                result.append("%%");
                break;
            default:
                result.append("%"); // copy pattern escape and move on
                j--;                // only want to bump by one position....
                break;
            }
            i = j+2;
        }

        return result.toString();
    }
Static insertDate method will insert date fragments into a string
based on '%x' pattern elements.  Equivalents in SimpleDateFormatter patterns,
with examples:
<ul>
<li>%Y  YYYY  2003
<li>%m  MM  08
<li>%x  MMM  Aug
<li>%d  dd  25
<li>%H  HH  14
<li>%M  mm  30
<li>%S  ss  35
<li>%s  SSS  123
<li>%Z  Z -0400
</ul>
Others:
<ul>
<li>%T Long.toString(time)
<li>%%  %
</ul>
container-core/src/main/java/com/yahoo/container/logging/LogFormatter.java