Java Parse Date Pattern YYYY parseYmd(String s)

Here you can find the source of parseYmd(String s)

Description

Utility method to parse a date in the given format

License

Open Source License

Parameter

Parameter Description
s the string to parse
format the date format

Return

a Date representing the date in the passed format

Declaration

public static Date parseYmd(String s) 

Method Source Code

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

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    /**//  w w w. ja  v  a2s .  com
     * Utility method to parse a date in the given format
     * @param s the string to parse
     * @param format the date format
     * @return a Date representing the date in the passed format
     */
    public static Date parseYmd(String s) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return df.parse(s);
        } catch (Exception e) {
            throw new RuntimeException("Cannot parse " + s
                    + " into a date using ymd format");
        }
    }
}

Related

  1. parseWsDate(String date)
  2. parseXEP0082Date(String dateString)
  3. parseXsdDate(final Date date)
  4. parseXsdDateTime(String date)
  5. parseYmd(String date)
  6. parseYmdDate(String dateString)
  7. parseYMDToDate(String dateString)