Android Date Format fromString(String dateStr, String dateFormat)

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

Description

from String

License

Open Source License

Declaration

public static Date fromString(String dateStr, String dateFormat)
            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);
    }/*  w w  w .j  a va 2s .co  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. formatDate(long millis)
  2. formatDate1(String date)
  3. formatDateAndTime(long millis)
  4. formatTM(Date d)
  5. fromString(String dateStr)
  6. fromString(String dateStr, String dateFormat, Locale locale)
  7. getBeforeYear()
  8. getCurrentDate()
  9. getCurrentDateString(String dateFormat)