Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { /** * Get the SunSet for the given date * @param date - input date * @return - Date with time specifying the Sun Set */ public static Date getSunSet(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 18); cal.set(Calendar.MINUTE, 00); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date ret = cal.getTime(); return ret; } }