Java Long Number to Time stringTolong(String time)

Here you can find the source of stringTolong(String time)

Description

string Tolong

License

Open Source License

Declaration

public static long stringTolong(String time) 

Method Source Code


//package com.java2s;

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

import java.util.Date;

public class Main {
    public static long stringTolong(String time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date dt2;/*from w ww .  j  a va  2s .c om*/
        long lTime = 0;
        try {
            if (time != null && !time.equals("")) {
                dt2 = sdf.parse(time);
                lTime = dt2.getTime();
            } else {
                return lTime;
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return lTime;
    }
}

Related

  1. prettyDate(long time)
  2. printDuration(String message, long startTime)
  3. printExecutionTime(long startTime, long endTime, String className, String methodName)
  4. str2Long(String time)
  5. stringTime(long time)
  6. time2Date(Long time)
  7. time2DATETIME(long time)
  8. toLong(String time)
  9. toLongString(long ms)