convert LocalTime To Relative Time - Java java.time

Java examples for java.time:LocalTime

Description

convert LocalTime To Relative Time

Demo Code


//package com.java2s;

import java.time.*;

public class Main {
    /**//from  w w  w .java2 s .  com
     * @param time
     * @return int From Localtime(Hour,Minute,Second) to seconds
     */
    public static int convertToRelativeTime(LocalTime time) {
        int hour = time.getHour();
        int minute = time.getMinute();
        int second = time.getSecond();

        return hour * 3600 + minute * 60 + second;
    }
}

Related Tutorials