Java Millisecond Convert getTimeMillis(String time)

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

Description

get Time Millis

License

Apache License

Declaration

public static long getTimeMillis(String time) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static long getTimeMillis(String time) {
        try {//from   ww  w .  j  a v a  2  s .c o m
            DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
            DateFormat dayFormat = new SimpleDateFormat("yy-MM-dd");
            Date curDate = dateFormat.parse(dayFormat.format(new Date()) + " " + time);
            return curDate.getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }
}

Related

  1. getTime(long time, boolean withMilliseconds)
  2. getTimeByMillis(long now)
  3. getTimeFromMillisAsNICSDate(long timeInMillis)
  4. getTimeInMillisFromNicsDateString(String dateString)
  5. getTimeMillis(String dateStr)
  6. getTimestamp(long milliseconds)
  7. getTimestampMillis(Locale locale)
  8. getTimeStr(final long millis)
  9. getTimeString(long millis)