Java Locale Format formatString2Date(String dateString)

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

Description

format String Date

License

Open Source License

Declaration

public static final Date formatString2Date(String dateString) 

Method Source Code

//package com.java2s;

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

import java.util.Date;

import java.util.Locale;

public class Main {
    public static final Date formatString2Date(String dateString) {
        SimpleDateFormat sdf = new SimpleDateFormat();
        Date datum = new Date();
        try {//from   w  w w.j a va  2  s .co  m
            datum = sdf.parse(dateString);
            return datum;
        } catch (ParseException e) {
            //logger.error(e.getMessage());
            return null;
        }

    }

    public static final Date formatString2Date(String dateString, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date datum = new Date();
        try {
            datum = sdf.parse(dateString);
            return datum;
        } catch (ParseException e) {
            //logger.error(e.getMessage());
            return null;
        }

    }

    public static final Date formatString2Date(String dateString, String format, Locale locale) {
        SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
        Date datum = new Date();
        try {
            datum = sdf.parse(dateString);
            return datum;
        } catch (ParseException e) {
            //logger.error(e.getMessage());
            return null;
        }

    }
}

Related

  1. formatPCT(Object num)
  2. formatPersent(Object input)
  3. formatSmartDate(Date date)
  4. formatString(Object[] args)
  5. formatString(String pattern, Object... args)
  6. formattedFromDouble(double d, int scale, Locale locale)
  7. formattedFromLong(long l, Locale locale)
  8. formattedToDouble(String str, Locale loc)
  9. formatTime(Calendar calendar, String format)