Java Date Format Change convertDate(String inPattern, String outPattern, String date)

Here you can find the source of convertDate(String inPattern, String outPattern, String date)

Description

convert Date

License

Open Source License

Declaration

public static String convertDate(String inPattern, String outPattern, String date) throws Exception 

Method Source Code


//package com.java2s;
/*//  w  ww  .ja va2 s  .co 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 {
    public static String convertDate(String inPattern, String outPattern, String date) throws Exception {
        Date newDate = getDate(inPattern, date);
        return formatDate(outPattern, newDate);
    }

    public static Date getDate(String pattern, String date) throws Exception {
        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
        return formatter.parse(date);
    }

    public static String formatDate(String pattern, Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
        return formatter.format(date);
    }
}

Related

  1. changeDateTimeZone(String date_GMT)
  2. changeDateValue(Date firstDate, Date secondDate)
  3. convertDate(String date, String sourceFormat, String destinationFormat)
  4. convertDate(String date, String[] formats)
  5. convertDate(String dateIn, String fromDateFormat, String toDateFormat)
  6. convertDate(String inPattern, String outPattern, String date)
  7. convertDate(String str)
  8. convertDate(String value)
  9. convertDateFormat(String date, SimpleDateFormat formatBefore, SimpleDateFormat formatAfter)