Package gw.date
Class GosuDateUtil
java.lang.Object
gw.date.GosuDateUtil
Utilities for java.util.Date objects. These utilities are not intended to be used directly; use the corresponding
enhancements on Date instead.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Date
Adds the specified (signed) amount of days to the given date.static Date
Adds the specified (signed) amount of hours to the given date.static Date
addMinutes
(Date date, int iMinutes) Adds the specified (signed) amount of minutes to the given date.static Date
Adds the specified (signed) amount of months to the given date.static Date
addSeconds
(Date date, int iSeconds) Adds the specified (signed) amount of seconds to the given date.static Date
Adds the specified (signed) amount of weeks to the given date.static Date
Adds the specified (signed) amount of years to the given date.private static Calendar
dateToCalendar
(Date date) static int
getDayOfMonth
(Date date) Get the day of month.static int
getDayOfWeek
(Date date) Get the day of week.static int
getDayOfYear
(Date date) Get the day of year.static int
Get the hour of the time, base on a 12-hour clock.static int
getHourOfDay
(Date date) Get the hour of the time, based on a 24-hour clock.static int
Get the minute of the timestatic int
The month of the year.static int
Get the second of the timestatic int
getWeekOfMonth
(Date date) Get the week of month.static int
getWeekOfYear
(Date date) Get the week of the year.static int
Get the year.static boolean
Is the time AM?static boolean
Is the time PM?
-
Constructor Details
-
GosuDateUtil
public GosuDateUtil()
-
-
Method Details
-
addSeconds
Adds the specified (signed) amount of seconds to the given date. For example, to subtract 5 seconds from the current time of the date, you can achieve it by calling:addSeconds(Date, -5)
.- Parameters:
date
- The time.iSeconds
- The amount of seconds to add.- Returns:
- A new date with the seconds added.
-
addMinutes
Adds the specified (signed) amount of minutes to the given date. For example, to subtract 5 minutes from the current time of the date, you can achieve it by calling:addMinutes(Date, -5)
.- Parameters:
date
- The time.iMinutes
- The amount of minutes to add.- Returns:
- A new date with the minutes added.
-
addHours
Adds the specified (signed) amount of hours to the given date. For example, to subtract 5 hours from the current date, you can achieve it by calling:addHours(Date, -5)
.- Parameters:
date
- The time.iHours
- The amount of hours to add.- Returns:
- A new date with the hours added.
-
addDays
Adds the specified (signed) amount of days to the given date. For example, to subtract 5 days from the current date, you can achieve it by calling:addDays(Date, -5)
.- Parameters:
date
- The time.iDays
- The amount of days to add.- Returns:
- A new date with the days added.
-
addWeeks
Adds the specified (signed) amount of weeks to the given date. For example, to subtract 5 weeks from the current date, you can achieve it by calling:addWeeks(Date, -5)
.- Parameters:
date
- The time.iWeeks
- The amount of weeks to add.- Returns:
- A new date with the weeks added.
-
addMonths
Adds the specified (signed) amount of months to the given date. For example, to subtract 5 months from the current date, you can achieve it by calling:addMonths(Date, -5)
.- Parameters:
date
- The time.iMonths
- The amount of months to add.- Returns:
- A new date with the months added.
-
addYears
Adds the specified (signed) amount of years to the given date. For example, to subtract 5 years from the current date, you can achieve it by calling:addYears(Date, -5)
.- Parameters:
date
- The time.iYears
- The amount of years to add.- Returns:
- A new date with the years added.
-
getSecond
Get the second of the time- Parameters:
date
- The time.- Returns:
- The second of the time, always in the range 0-59
-
getMinute
Get the minute of the time- Parameters:
date
- The time.- Returns:
- The minute of the time, always in the range 0-59
-
getHour
Get the hour of the time, base on a 12-hour clock.- Parameters:
date
- The time.- Returns:
- The hour of the time. Based on a 12-hour clock.
-
isAM
Is the time AM?- Parameters:
date
- The time.- Returns:
- true if the time is AM, false otherwise
-
isPM
Is the time PM?- Parameters:
date
- The time.- Returns:
- true if the time is PM, false otherwise
-
getHourOfDay
Get the hour of the time, based on a 24-hour clock.- Parameters:
date
- The time.- Returns:
- The hour of the time. Based on a 24-hour clock.
-
getDayOfWeek
Get the day of week.- Parameters:
date
- The date.- Returns:
- The day of week. Sunday = 1, Monday = 2, ..., Saturday = 7.
-
getDayOfMonth
Get the day of month.- Parameters:
date
- The date.- Returns:
- The day of the month. The first day = 1.
-
getDayOfYear
Get the day of year.- Parameters:
date
- The date.- Returns:
- The day number of the year. The first day = 1.
-
getWeekOfMonth
Get the week of month.- Parameters:
date
- The date.- Returns:
- The week within the month. The first week = 1.
-
getWeekOfYear
Get the week of the year.- Parameters:
date
- The date.- Returns:
- The week of the year. The first week = 1.
-
getMonth
The month of the year.- Parameters:
date
- The date- Returns:
- The month of the year, in the range 1-12
-
getYear
Get the year.- Parameters:
date
- The date.- Returns:
- The year of the date.
-
dateToCalendar
-