Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Date; public class Main { public static int betweenSec(Date from, Date to) { long duration = from.getTime() - to.getTime(); return (int) (duration / (1000)); } }