Java Time Format string2long(String sourceTime, String dataFormat)

Here you can find the source of string2long(String sourceTime, String dataFormat)

Description

stringlong

License

Open Source License

Declaration

public static long string2long(String sourceTime, String dataFormat) 

Method Source Code

//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static long string2long(String sourceTime, String dataFormat) {
        long longTime = 0L;
        DateFormat f = new SimpleDateFormat(dataFormat);
        Date d = null;//from  w ww.  j a  v  a 2 s .  c  om
        try {
            d = f.parse(sourceTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (null == d)
            longTime = 0;
        else
            longTime = d.getTime();

        return longTime;
    }
}

Related

  1. printDate(final long time, final String dateFormat)
  2. printFormatDate(long dateTime)
  3. setDateTimeFormat(String format)
  4. stdTimeFormat(Date date)
  5. string2Long(String sourceTime, String dataFormat)
  6. stringDateTimeFormat(String dt2Format)
  7. stringTimeToLongTime(String time, String format)
  8. stringToTime(String format, String sDate)
  9. time2Date(Integer time, String format)