Android Date Format fromString(String dateStr, String dateFormat, Locale locale)

Here you can find the source of fromString(String dateStr, String dateFormat, Locale locale)

Description

from String

License

Open Source License

Declaration

public static Date fromString(String dateStr, String dateFormat,
            Locale locale) throws java.text.ParseException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

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

public class Main {
    public static final String DATE_FORMAT = "yyyy-MM-dd G HH:mm:ss z";

    public static Date fromString(String dateStr)
            throws java.text.ParseException {
        return fromString(dateStr, DATE_FORMAT);
    }/*ww  w .  j a  v  a2s . c  o m*/

    public static Date fromString(String dateStr, String dateFormat)
            throws java.text.ParseException {
        return fromString(dateStr, dateFormat, Locale.ENGLISH);
    }

    public static Date fromString(String dateStr, String dateFormat,
            Locale locale) throws java.text.ParseException {
        SimpleDateFormat format = new SimpleDateFormat(dateFormat, locale);
        return format.parse(dateStr);
    }
}

Related

  1. formatDate1(String date)
  2. formatDateAndTime(long millis)
  3. formatTM(Date d)
  4. fromString(String dateStr)
  5. fromString(String dateStr, String dateFormat)
  6. getBeforeYear()
  7. getCurrentDate()
  8. getCurrentDateString(String dateFormat)
  9. getCurrentDateTime()