Java Hour Format formatDateString(String dateString)

Here you can find the source of formatDateString(String dateString)

Description

format Date String

License

Open Source License

Declaration

public static String formatDateString(String dateString) 

Method Source Code

//package com.java2s;
/**//from   w w  w  .j a v  a 2 s  .com
 * Created on Aug 9, 2004
 *
 * Copyright 2005 by Arysys Technologies (P) Ltd.,
 * #3,Shop line,
 * Sasmira Marg,
 * Worli,Mumbai 400 025
 * India
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Arysys Technologies (P) Ltd. ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Arysys Technologies (P) Ltd.
 *
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String formatDateString(String dateString) {
        try {
            if ("".equals(dateString) || dateString == null) {
                return null;
            }

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = sdf.parse(dateString);

            sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
            return sdf.format(date);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}

Related

  1. formatDateAsString(Date date)
  2. formatDateForCERMe(Date date, boolean includeTime)
  3. formatDateInTime(Date date)
  4. formatDateRfc822(Date date, String timeZoneId)
  5. formatDateString(Date d)
  6. formatDateString2(String str_date)
  7. formatDateTime()
  8. formatDateTime(Calendar cal)
  9. formatDateTime(Calendar dateTime)