diff options
author | Robert Antoni Buj i Gelonch <robert.buj@gmail.com> | 2014-09-29 11:58:04 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2014-09-29 12:44:30 +0000 |
commit | 72f50083e713bb4f25b6acc31ecad3ae7aa9050e (patch) | |
tree | bcdefb65964fc8b566bc913379a901eeb1d01ee3 /forms/qa | |
parent | 014e7933af751bfe0a03867373b82efa806f3a3d (diff) |
forms: getMonth() and getYear() are deprecated in java.util.Date
Change-Id: I31664bbd8c1c3b02e8a7381226d4d558b37466a2
Reviewed-on: https://gerrit.libreoffice.org/11690
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'forms/qa')
-rw-r--r-- | forms/qa/integration/forms/DateValidator.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/forms/qa/integration/forms/DateValidator.java b/forms/qa/integration/forms/DateValidator.java index 0264642eacb3..76cb6ca6a0fb 100644 --- a/forms/qa/integration/forms/DateValidator.java +++ b/forms/qa/integration/forms/DateValidator.java @@ -72,12 +72,11 @@ public class DateValidator extends integration.forms.ControlValidator private boolean isNextMonthsDate( com.sun.star.util.Date dateValue ) { - int overallMonth = dateValue.Year * 12 + dateValue.Month - 1; - - int todaysMonth = new java.util.Date().getMonth(); - int todaysYear = new java.util.Date().getYear() + 1900; - int todaysOverallMonth = todaysYear * 12 + todaysMonth; - - return overallMonth == todaysOverallMonth; + java.util.Calendar today = java.util.Calendar.getInstance(); + java.util.Calendar date = (java.util.Calendar) today.clone(); + today.set(java.util.Calendar.DATE, 1); + date.set(dateValue.Year, dateValue.Month, 1); + date.add(java.util.Calendar.MONTH, -1); + return date.compareTo(today) == 0; } } |