From ef967ef1fded0f5dbedf2599d5eb4846f7bd6277 Mon Sep 17 00:00:00 2001 From: samskivert Date: Wed, 26 Aug 2009 22:35:15 +0000 Subject: [PATCH] Nixed setHour() and setMinute() as the concensus is that you'll addHour(), etc. from a midnighted calendar. Also added at(year, month, day) to the builder so that you can do: Calendars.in(zone).at(2009, Calendar.JANUARY, 1) git-svn-id: https://samskivert.googlecode.com/svn/trunk@2624 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/Calendars.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/java/com/samskivert/util/Calendars.java b/src/java/com/samskivert/util/Calendars.java index 4ae1b404..5bc55c8c 100644 --- a/src/java/com/samskivert/util/Calendars.java +++ b/src/java/com/samskivert/util/Calendars.java @@ -66,23 +66,12 @@ public class Calendars return add(Calendar.DATE, days); } - /** Sets the {@link Calendar#HOUR_OF_DAY} field to the specified value. This uses a 24-hour - * clock. Midnight is 0. */ - public Builder setHour (int hour) { - return set(Calendar.HOUR_OF_DAY, hour); - } - /** Adds the specified value to the {@link Calendar#HOUR_OF_DAY} field. Use negative values * to subtract. */ public Builder addHours (int hours) { return add(Calendar.HOUR_OF_DAY, hours); } - /** Sets the {@link Calendar#MINUTE} field to the specified value. */ - public Builder setMinute (int minute) { - return set(Calendar.MINUTE, minute); - } - /** Adds the specified value to the {@link Calendar#MINUTE} field. Use negative values to * subtract. */ public Builder addMinutes (int minutes) { @@ -107,6 +96,14 @@ public class Calendars return this; } + /** Sets the year, month and day to the specified values and the time to zero millseconds + * after midnight on that date. This mirrors {@link Calendars#at} for when you need e.g. a + * custom timezone:
Calendars.in(zone).at(2009, Calendar.JANUARY, 1)
*/ + public Builder at (int year, int month, int day) { + _calendar.set(year, month, day); + return zeroTime(); + } + /** Zeros out the time fields of this calendar, preserving only the date. */ public Builder zeroTime () { _calendar.set(Calendar.HOUR_OF_DAY, 0);