Java Hour Format format(String str)

Here you can find the source of format(String str)

Description

format

License

Apache License

Declaration

public static String format(String str) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static String format(String str) {
        return String.format("%tF", parse(str, "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US));
    }/*  w w w.j  a v a  2  s  .  c om*/

    public static String format(Date date, String pattern, Locale locale) {
        if (date == null || pattern == null) {
            return null;
        }
        return new SimpleDateFormat(pattern, locale).format(date);
    }

    public static Date parse(String str, String pattern, Locale locale) {
        if (str == null || pattern == null) {
            return null;
        }
        try {
            return new SimpleDateFormat(pattern, locale).parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. format(long time)
  2. format(long time)
  3. format(Number price)
  4. format(String format, Date val)
  5. format(String pattern)
  6. format16ByDate(Date aDate)
  7. format1StringToformat2String(String dateStr)
  8. format2NormalTime(Date date)
  9. format_default(Date time)