Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static Calendar GetLastYearRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.MONTH, 0); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; } }