public class DateTimeService extends Object
| Constructor and Description |
|---|
DateTimeService()
Creates a new date time service with the application default locale.
|
DateTimeService(String locale)
Creates a new date time service with a given locale.
|
| Modifier and Type | Method and Description |
|---|---|
String |
formatDate(Date date,
String formatStr)
Check if format contains the month name.
|
String[] |
getAmPmStrings() |
String |
getClockDelimeter() |
String |
getDay(int day) |
int |
getFirstDayOfWeek() |
static int |
getISOWeekNumber(Date date)
Returns the ISO-8601 week number of the given date.
|
String |
getLocale() |
static int |
getMilliseconds(Date date) |
String |
getMonth(int month) |
static int |
getNumberOfDaysInMonth(Date date) |
String |
getShortDay(int day) |
String |
getShortMonth(int month) |
int |
getStartWeekDay(Date date) |
static boolean |
isInRange(Date date,
Date rangeStart,
Date rangeEnd,
Resolution resolution) |
static boolean |
isLeapYear(Date date) |
static boolean |
isSameDay(Date d1,
Date d2) |
boolean |
isTwelveHourClock() |
Date |
parseDate(String dateString,
String formatString,
boolean lenient)
Parses the given date string using the given format string and the locale
set in this DateTimeService instance.
|
void |
setLocale(String locale) |
static void |
setMilliseconds(Date date,
int ms) |
public DateTimeService()
public DateTimeService(String locale) throws LocaleNotLoadedException
locale - e.g. fi, en etc.LocaleNotLoadedExceptionpublic void setLocale(String locale) throws LocaleNotLoadedException
LocaleNotLoadedExceptionpublic String getLocale()
public String getMonth(int month)
public String getShortMonth(int month)
public String getDay(int day)
public String getShortDay(int day)
public int getFirstDayOfWeek()
public boolean isTwelveHourClock()
public String getClockDelimeter()
public String[] getAmPmStrings()
public int getStartWeekDay(Date date)
public static void setMilliseconds(Date date, int ms)
public static int getMilliseconds(Date date)
public static int getNumberOfDaysInMonth(Date date)
public static boolean isLeapYear(Date date)
public static boolean isInRange(Date date, Date rangeStart, Date rangeEnd, Resolution resolution)
public static int getISOWeekNumber(Date date)
date - The date for which the week number should be resolvedpublic String formatDate(Date date, String formatStr)
date - The date to convertformatStr - The format string that might contain MMM or MMMMdateTimeService - Reference to the Vaadin DateTimeServicepublic Date parseDate(String dateString, String formatString, boolean lenient) throws IllegalArgumentException
dateString - Date string e.g. "1 February 2010"formatString - Format string e.g. "d MMMM yyyy"lenient - true to use lenient parsing, false to use strict parsingIllegalArgumentException - if the parsing failsCopyright © 2016 Vaadin Ltd. All rights reserved.