<p>Formats a date/time into a specific pattern using the UTC time zone.</p>

@param millis  the date to format expressed in milliseconds
@param pattern  the pattern to use to format the date, not null
@return the formatted date
509181
public static String formatUTC(final long millis, final String pattern) {
        return format(new Date(millis), pattern, UTC_TIME_ZONE, null);
    }
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;
	}
811590
public static String format(double number, String pattern) {
		DecimalFormat df = null;
		if (StringUtils.isEmpty(pattern)) {
			df = PRETTY_FORMAT.get();
		} else {
			df = (DecimalFormat) DecimalFormat.getInstance();
			df.applyPattern(pattern);
		}

		return df.format(number);
	}
403998
public static String getFormatDate(String format, Date date, String zoneId) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format);
        return dateTimeFormatter
            .format(date.toInstant().atZone(ZoneId.of(zoneId)).toLocalDateTime());
    }
655287
public static String format(ITemplate template, Date date, String pattern, Locale locale, String timezone) {
        if (null == date) throw new NullPointerException();
        RythmEngine engine = null == template ? RythmEngine.get() : template.__engine();
        DateFormat df =  (null == engine ? IDateFormatFactory.DefaultDateFormatFactory.INSTANCE : engine.dateFormatFactory()).createDateFormat(template, pattern, locale, timezone);

        return df.format(date);
    }
207022
public synchronized static String formatTime(final Time object, String pattern) {
		if (pattern == null || pattern.equals("")) {
			pattern = JKFormatUtil.DEFAULT_TIME_PATTERN;
		}
		return JKFormatUtil.getDateFormatter(pattern).format(object);
	}
881581
public static String format(final LocalTime self, String pattern) {
        return self.format(DateTimeFormatter.ofPattern(pattern));
    }
966705
public static String formatUnixTime(String style, BigInteger unixtime){
		SimpleDateFormat sdf = new SimpleDateFormat(style);
		return sdf.format(unixtime);
	}
224999
public static TimestampFormatter createTimestampFormatter(final String pattern, final Locale locale) {
		return dialect.createTimestampFormatter(pattern, locale);
	}
1214424
public static Calendar toCalendar(final long millis)
	{
		final Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(millis);
		return calendar;
	}
103125
static DateFormat getBasicDateFormatter() {
        String pattern;
        int patternLength;
        int endOfSecsIndex;
        // Retrieve a standard Java DateFormat object with desired format.
        DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
        if (formatter instanceof SimpleDateFormat) {
            // Retrieve the pattern from the formatter, since we will need to modify it.
            SimpleDateFormat sdFormatter = (SimpleDateFormat) formatter;
            pattern = sdFormatter.toPattern();
            // Append milliseconds and timezone after seconds
            patternLength = pattern.length();
            endOfSecsIndex = pattern.lastIndexOf('s') + 1;
            String newPattern = pattern.substring(0, endOfSecsIndex) + ":SSS z";
            if (endOfSecsIndex < patternLength)
                newPattern += pattern.substring(endOfSecsIndex, patternLength);
            // 0-23 hour clock (get rid of any other clock formats and am/pm)
            newPattern = newPattern.replace('h', 'H');
            newPattern = newPattern.replace('K', 'H');
            newPattern = newPattern.replace('k', 'H');
            newPattern = newPattern.replace('a', ' ');
            newPattern = newPattern.trim();
            sdFormatter.applyPattern(newPattern);
            formatter = sdFormatter;
        } else {
            formatter = new SimpleDateFormat("yy.MM.dd HH:mm:ss:SSS z");
        }
        // PK13288 Start
        if (sysTimeZone != null) {
            formatter.setTimeZone(sysTimeZone);
        }
        // PK13288 End.
        return formatter;
    }
268640
public static String timeFormat(final long milliseconds) {
        double seconds = milliseconds / 1000.0d;
        final NumberFormat fmt = new DecimalFormat("#0.000");
        return fmt.format(seconds);
    }
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;
    }
707798
public static String fromUnixtime(long unixtime, String format, TimeZone tz) {
		SimpleDateFormat formatter = FORMATTER_CACHE.get(format);
		formatter.setTimeZone(tz);
		Date date = new Date(unixtime * 1000);
		try {
			return formatter.format(date);
		} catch (Exception e) {
			LOG.error("Exception when formatting.", e);
			return null;
		}
	}
216917
public static Expression millisToUtc(String expression, String format) {
        return millisToUtc(x(expression), format);
    }
25762
public static boolean isValid(String date, String pattern) {
        Date d = parseDate(date, pattern);
        return d != null && format(d, pattern).equals(date);
    }
252348
public static Date parse(String date, String pattern) {
		return DateTimeFormat.forPattern(pattern).parseDateTime(date).toDate();
	}