Java tutorial
import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] args) throws Throwable { SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); Date date1 = format.parse("08:00:01"); Date date2 = format.parse("23:00:05"); Date date = new Date(date2.getTime() - date1.getTime()); System.out.println(format.format(date)); } }