Package rs.baselib.util
Class RsDate
java.lang.Object
java.util.Calendar
java.util.GregorianCalendar
rs.baselib.util.RsDate
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<java.util.Calendar>
public class RsDate
extends java.util.GregorianCalendar
A
Date replacement object to allow better date computations.- Author:
- ralph
- See Also:
- Serialized Form
-
Nested Class Summary
-
Field Summary
Fields inherited from class java.util.Calendar
ALL_STYLES, AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET -
Constructor Summary
Constructors Constructor Description RsDate()Constructor.RsDate(int year, int month, int dayOfMonth)Constructor with default timezone.RsDate(int year, int month, int dayOfMonth, int hourOfDay, int minute)Constructor with default timezone.RsDate(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)Constructor with default timezone.RsDate(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)Constructor with default timezone.RsDate(long timeInMillis)Constructor.RsDate(java.util.Calendar calendar)Constructor.RsDate(java.util.Date date)Constructor.RsDate(java.util.TimeZone timezone)Constructor.RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth)Constructor.RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute)Constructor.RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)Constructor.RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)Constructor.RsDate(java.util.TimeZone timezone, long timeInMillis)Constructor.RsDate(java.util.TimeZone timezone, java.util.Date date)Constructor. -
Method Summary
Modifier and Type Method Description static RsDateget(long timestamp)Create a date of given timestamp or null.static RsDateget(java.sql.Timestamp timestamp)Create a date of given timestamp or null.static RsDateget(java.util.Date date)Create a date of given timestamp or null.RsDaygetDay()Returns the day object for this date.RsMonthgetMonth()Returns the month object for this date.RsYeargetYear()Returns the year object for this date.java.lang.StringtoString()Methods inherited from class java.util.GregorianCalendar
add, clone, computeFields, computeTime, equals, from, getActualMaximum, getActualMinimum, getCalendarType, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, getWeeksInWeekYear, getWeekYear, hashCode, isLeapYear, isWeekDateSupported, roll, roll, setGregorianChange, setTimeZone, setWeekDate, toZonedDateTimeMethods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, complete, get, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toInstant
-
Constructor Details
-
RsDate
public RsDate()Constructor. -
RsDate
public RsDate(java.util.TimeZone timezone)Constructor.- Parameters:
timezone- - the timezone for this date- Since:
- 1.2.8
-
RsDate
public RsDate(java.util.Date date)Constructor.- Parameters:
date- - init with this date
-
RsDate
public RsDate(java.util.TimeZone timezone, java.util.Date date)Constructor.- Parameters:
timezone- - the timezone for this datedate- - init with this date
-
RsDate
public RsDate(long timeInMillis)Constructor.- Parameters:
timeInMillis- - init with this timestamp
-
RsDate
public RsDate(java.util.TimeZone timezone, long timeInMillis)Constructor.- Parameters:
timeInMillis- - init with this timestamptimezone- - the timezone for this date
-
RsDate
public RsDate(java.util.Calendar calendar)Constructor.- Parameters:
calendar- - init with calendar time
-
RsDate
public RsDate(int year, int month, int dayOfMonth)Constructor with default timezone.time will be 00:00:00.000.
- Parameters:
year- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)- Since:
- 1.2.7
-
RsDate
public RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth)Constructor.time will be 00:00:00.000.
- Parameters:
timezone- the timezone to be usedyear- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)- Since:
- 1.2.8
-
RsDate
public RsDate(int year, int month, int dayOfMonth, int hourOfDay, int minute)Constructor with default timezone.Calendar.SECONDs andCalendar.MILLISECONDs will be 0.- Parameters:
year- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)hourOfDay- hoir of day (0-23)minute- minute value (0-59)- Since:
- 1.2.7
-
RsDate
public RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute)Constructor.Calendar.SECONDs andCalendar.MILLISECONDs will be 0.- Parameters:
timezone- the timezone to be usedyear- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)hourOfDay- hoir of day (0-23)minute- minute value (0-59)- Since:
- 1.2.8
-
RsDate
public RsDate(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)Constructor with default timezone.Calendar.MILLISECONDs will be 0.- Parameters:
year- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)hourOfDay- hoir of day (0-23)minute- minute value (0-59)seconds- seconds value(0-59)- Since:
- 1.2.7
-
RsDate
public RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)Constructor.Calendar.MILLISECONDs will be 0.- Parameters:
timezone- the timezone to be usedyear- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)hourOfDay- hoir of day (0-23)minute- minute value (0-59)seconds- seconds value(0-59)- Since:
- 1.2.8
-
RsDate
public RsDate(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)Constructor with default timezone.- Parameters:
year- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)hourOfDay- hoir of day (0-23)minute- minute value (0-59)seconds- seconds value(0-59)milliseconds- milliseconds value (0-999)- Since:
- 1.2.7
-
RsDate
public RsDate(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)Constructor.- Parameters:
timezone- the timezone to be usedyear- year valuemonth- month value (0-11)dayOfMonth- day of month value (1-31)hourOfDay- hoir of day (0-23)minute- minute value (0-59)seconds- seconds value(0-59)milliseconds- milliseconds value (0-999)- Since:
- 1.2.8
-
-
Method Details
-
getYear
Returns the year object for this date.- Returns:
- year
-
getMonth
Returns the month object for this date.- Returns:
- month
-
getDay
Returns the day object for this date.- Returns:
- day
-
get
Create a date of given timestamp or null.- Parameters:
date- date to be represented- Returns:
- the RsDate object
-
get
Create a date of given timestamp or null.- Parameters:
timestamp- time to be represented- Returns:
- the RsDate object
-
get
Create a date of given timestamp or null.- Parameters:
timestamp- timestamp- Returns:
- RsDate object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.util.Calendar
-