Here you can find the source of formatDate(String pattern, Date date)
Parameter | Description |
---|---|
pattern | The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss"). |
date | The java.util.Date object to format. |
public static String formatDate(String pattern, Date date)
//package com.java2s; /*//ww w . ja v a 2 s . c o m * Copyright (c) Mirth Corporation. All rights reserved. * * http://www.mirthcorp.com * * The software in this package is published under the terms of the MPL license a copy of which has * been included with this distribution in the LICENSE.txt file. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Formats a java.util.Date object into a string according to a specified pattern. * * @param pattern * The SimpleDateFormat pattern to use (e.g. "yyyyMMddHHmmss"). * @param date * The java.util.Date object to format. * @return The formatted date string. */ public static String formatDate(String pattern, Date date) { SimpleDateFormat formatter = new SimpleDateFormat(pattern); return formatter.format(date); } }