Java Date Format dateFormater(String dataStr, String dataFormat)

Here you can find the source of dateFormater(String dataStr, String dataFormat)

Description

date Formater

License

Apache License

Declaration

public static Date dateFormater(String dataStr, String dataFormat) 

Method Source Code


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

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

public class Main {
    public static Date dateFormater(String dataStr, String dataFormat) {
        DateFormat dateFormat = new SimpleDateFormat(dataFormat, Locale.ENGLISH);
        Date date = null;/*from  w  ww  .j  a v a  2  s  . c o  m*/
        try {
            date = dateFormat.parse(dataStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }

    public static String dateFormater(Date date, String dataFormat) {
        DateFormat formater = new SimpleDateFormat(dataFormat, Locale.ENGLISH);
        String dateStr = null;
        dateStr = formater.format(date);
        return dateStr;
    }
}

Related

  1. dateFormat3(Date date)
  2. dateFormat4yyyyMMdd()
  3. dateFormatCheck(String source)
  4. dateFormatCheck(String source, String format)
  5. dateformate(String reg, Date newdate)
  6. dateFormatString(Date date)
  7. dateFormatted(Date date)
  8. dateFormatter(String dateFormat)
  9. dateFormatTime(final Date date)