public class DateHelper extends Object
It uses CalendarConstants
interface for some calculations.
You can localize the helper using properties file placed in the folder org/gwt/advanced/client/resources
.
Modifier and Type | Field and Description |
---|---|
static int[] |
WEEK_END_DAYS
weekedn days (Sunday and Saturday)
|
Constructor and Description |
---|
DateHelper(Date date)
Creates an instance of this class.
|
DateHelper(int year,
int month,
int day,
int hours,
int minutes,
int seconds)
Creates an instance of this class.
|
Modifier and Type | Method and Description |
---|---|
Date |
addDays(int days)
This method adds days to the date.
|
Date |
addMonths(int months)
This method adds months to the date.
|
Date |
addYears(int years)
This method adds years to the date.
|
Date |
getDate()
Returns the date.
|
int |
getDay()
This method gets a day in the month.
|
int |
getDayOfWeek()
This method gets a week day number.
|
int |
getDaysFrom(Date startDate)
This method gets a number of days starting from the specified date.
|
Date |
getFirstDayOfMonth()
This method returns the first date of the month.
|
Date |
getFirstDayOfWeek()
This method returns the first date of the week.
|
int |
getHours()
This method gets a hours number from 0 to 23.
|
Date |
getLastDayOfMonth()
This method returns the last date of the month.
|
Date |
getLastDayOfWeek()
This method returns the last date of the week.
|
int |
getMinutes()
This method gets minutes number.
|
int |
getMonth()
This method gets a month in the year starting from 0.
|
int |
getNumberOfDaysInMonth()
This method gets a number of days in the month.
|
int |
getSeconds()
This method gets seconds number.
|
int |
getWeekNumber()
This method gets a week number starting from the first of January (the first week).
|
int |
getYear()
This method gets the year.
|
boolean |
isWeekEndDay()
Checks whether the date is weekend.
|
static boolean |
isWeekEndDay(int weekDay)
This method defines whether the specified week day is a weekend.
|
Date |
trim()
This method cuts time data from the date.
|
public static final int[] WEEK_END_DAYS
public DateHelper(Date date)
date
- is a date to operate with.public DateHelper(int year, int month, int day, int hours, int minutes, int seconds)
year
- is a year number.month
- is a month number (from 0 to 11).day
- is a day number.hours
- is a hours number (from 0 to 23).minutes
- is a minutes number.seconds
- is a seconds number.public int getDayOfWeek()
Usually a week starts from Sunday (0), but in some localizations it can start from Monday. In this case all numbers will be shifted, i.e. Monday (0), Tuesday (1),..., Sunday (6).
public int getDay()
public int getMonth()
public int getYear()
public int getHours()
public int getMinutes()
public int getSeconds()
public int getNumberOfDaysInMonth()
public Date trim()
public Date addDays(int days)
days
- a number of days to add.public Date addMonths(int months)
months
- a number of months to add.public Date addYears(int years)
years
- a number of years to add.public int getWeekNumber()
public Date getFirstDayOfWeek()
public Date getLastDayOfWeek()
public int getDaysFrom(Date startDate)
startDate
- is a start date.public Date getFirstDayOfMonth()
public Date getLastDayOfMonth()
public static boolean isWeekEndDay(int weekDay)
weekDay
- is a week day number.true
if the day is weekend.public boolean isWeekEndDay()
public Date getDate()
Copyright © 2008–2013. All rights reserved.