Java Parse Time ParseTime(final String time)

Here you can find the source of ParseTime(final String time)

Description

Parse Time

License

Open Source License

Declaration

public static final long ParseTime(final String time) throws ParseException 

Method Source Code


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

import java.text.ParseException;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    public static final long ParseTime(final String time) throws ParseException {
        final String[] timeString = time.split(":");
        int hour = Integer.parseInt(timeString[0]), minute = Integer.parseInt(timeString[1]),
                second = Integer.parseInt(timeString[2]);

        Calendar now = new GregorianCalendar();
        now.set(Calendar.HOUR_OF_DAY, hour);
        now.set(Calendar.MINUTE, minute);
        now.set(Calendar.SECOND, second);

        return now.getTimeInMillis();
    }/*from  w  w  w  . j ava2 s.  c  om*/
}

Related

  1. parseTime(Calendar c, String time)
  2. parseTime(char[] timeChars)
  3. parseTime(String currDate, String format)
  4. parseTime(String date, String format)
  5. parseTime(String s)
  6. parseTime(String sTime)