Java Hour Format formatStrToDate(String value, String pattern)

Here you can find the source of formatStrToDate(String value, String pattern)

Description

format Str To Date

License

Apache License

Declaration

public static java.util.Date formatStrToDate(String value, String pattern) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;

public class Main {

    public static java.util.Date formatStrToDate(String value, String pattern) {
        java.text.SimpleDateFormat format = null;
        if (null == pattern) {
            format = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        } else {/*  ww  w . ja  v  a2  s . c o  m*/
            format = new java.text.SimpleDateFormat(pattern);
        }
        try {
            return format.parse(value);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. formatSqlDateTime(Date value)
  2. formatSSLValid(Date validFrom, Date validTo)
  3. formatStringTime(String dateTime)
  4. formatStringTimeToLong(String timeLine)
  5. formatStrToDate(String strDate, int format)
  6. formattedDate()
  7. formattedDate(java.util.Date date, String formatString)
  8. formattedDateToDate(String str)
  9. formattedStringToDate(String date)