Java Time Format getTime(String format, String date)

Here you can find the source of getTime(String format, String date)

Description

get Time

License

Apache License

Declaration

public static long getTime(String format, String date) 

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 long getTime(String format, String date) {

        if (format == null || "".equals(format))
            format = "yyyy-MM-dd";
        SimpleDateFormat simpledateformat = new SimpleDateFormat(format, Locale.SIMPLIFIED_CHINESE);
        Date d = null;/*  www.j a  va  2s. c om*/
        try {
            d = (Date) simpledateformat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return d.getTime();
    }
}

Related

  1. getTime(int format)
  2. getTime(long time, int timeFormat)
  3. getTime(String dateStr, String format)
  4. getTime(String dateStr, String formate)
  5. getTime(String format)
  6. getTime(String timeFormat)
  7. getTimeAfter(int field, int amount, String formatStr)
  8. getTimeAsString(final Date date, final String format)
  9. getTimeAsString(String timeFormatAsString)