DateHelper { public static Timestamp toTimestampUpper(Date date) { Timestamp timestamp = new Timestamp(date.getTime()); timestamp.setNanos(timestamp.getNanos() + 999999); return timestamp; } private  DateHelper(); static SimpleDateFormat getLocalDateFormat(Language language); static String getLocalDatePattern(Language language); static SimpleDateFormat getLocalDateTimeFormat(Language language); static String formatLocalDate(Date date, SimpleDateFormat dateFormat); static String formatShortDate(Date date); static String formatLocalDate(Date date, Language language); static String formatLocalDateTime(Date date, Language language); static String formatTime(Date date); static Date parseTime(String date); static Date parseDate(String date, SimpleDateFormat dateFormat); static Date parseDateWithException(String date); static String formatDateForExport(Date date); static String formatDateWithoutYear(Date date, Language language); static String formatDateWithMonthAbbreviation(Date date); static boolean isSameDay(Date firstDate, Date secondDate); static Date getDateZero(int year, int month, int day); static Date getTime(int hour, int minute); static List<Integer> getDaysInMonth(Integer month, Integer year); static List<Integer> getMonthsInYear(); static List<Integer> getYearsToNow(int startingYear); static List<Integer> getYearsToNow(); static int getFullDaysBetween(Date start, Date end); static int getDaysBetween(Date start, Date end); static List<Date> listDaysBetween(Date start, Date end); static int getWeeksBetween(Date start, Date end); static List<Date> listWeeksBetween(Date start, Date end); static int getMonthsBetween(Date start, Date end); static List<Date> listMonthsBetween(Date start, Date end); static int getYearsBetween(Date start, Date end); static List<Date> listYearsBetween(Date start, Date end); static Date addDays(Date date, int amountOfDays); static Date subtractDays(Date date, int amountOfDays); static Date addWeeks(Date date, int amountOfWeeks); static Date subtractWeeks(Date date, int amountOfWeeks); static Date addMonths(Date date, int amountOfMonths); static Date subtractMonths(Date date, int amountOfMonths); static Date addYears(Date date, int amountOfYears); static Date subtractYears(Date date, int amountOfYears); static Date addSeconds(Date date, int amountOfSeconds); static Date getStartOfDay(Date date); static Date getEndOfDay(Date date); static Date getStartOfWeek(Date date); static Date getEndOfWeek(Date date); static Date getStartOfMonth(Date date); static Date getEndOfMonth(Date date); static Date getStartOfYear(Date date); static Date getEndOfYear(Date date); static boolean isBetween(Date date, Date start, Date end); static Calendar getEpiCalendar(); static EpiWeek getEpiWeek(Date date); static EpiWeek getEpiWeekYearBefore(EpiWeek epiWeek); static EpiWeek getPreviousEpiWeek(Date date); static EpiWeek getPreviousEpiWeek(EpiWeek epiWeek); static EpiWeek getNextEpiWeek(Date date); static EpiWeek getNextEpiWeek(EpiWeek epiWeek); static Date getEpiWeekStart(EpiWeek epiWeek); static Date getEpiWeekEnd(EpiWeek epiWeek); static boolean isEpiWeekAfter(EpiWeek epiWeek, EpiWeek anotherEpiWeek); static int getMaximumEpiWeekNumber(); static List<EpiWeek> createEpiWeekList(int year); static List<EpiWeek> createEpiWeekList(int year, int week); static Date[] calculateEpiWeekReportStartAndEnd(
		Date now,
		EpiWeek epiWeek,
		Date weeklyReportDate,
		Date prevWeeklyReportDate,
		Date nextWeeklyReportDate); static Date[] findDateBounds(String value); static Integer[] findDatePrefix(String value); static Date toCorrectCentury(Date value); static Date toCorrectCentury(Date value, Date reference); static Timestamp toTimestampUpper(Date date); static long now(); static long startTime(); static long durationMillies(long startTimeMilliseconds); static long durationSeconds(long startTimeMilliseconds); static long toSeconds(long milliseconds);  }
@Test public void testToTimestampUpper() throws Exception { Date date = new Date(2323231232l); Timestamp timestamp = DateHelper.toTimestampUpper(date); assertEquals(date.getTime(), timestamp.getTime()); assertTrue(timestamp.after(new Timestamp(date.getTime()))); assertEquals(999999, timestamp.getNanos() % 1000000); }