Java Parse Date Pattern YYYY parse(String date)

Here you can find the source of parse(String date)

Description

parse

License

Open Source License

Declaration

public static long parse(String date) 

Method Source Code


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

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

public class Main {
    public static long parse(String date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {/* w  w  w  .j  ava2s  .  c o m*/
            return sdf.parse(date).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }

    public static long parse(String date, String pattern) {

        SimpleDateFormat sdft = new SimpleDateFormat(pattern);
        try {
            return sdft.parse(date).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
            return 0;
        }
    }
}

Related

  1. parse(String date)
  2. parse(String date)
  3. parse(String date)
  4. parse(String date)
  5. parse(String date)
  6. parse(String date)
  7. parse(String date)
  8. parse(String date)
  9. parse(String date)