public class OADateTime extends Object implements Serializable, Comparable
Modifier and Type | Field and Description |
---|---|
protected long |
_time |
protected String |
format |
static String |
FORMAT_long |
protected static String |
staticOutputFormat
default output format
|
protected TimeZone |
timeZone |
Constructor and Description |
---|
OADateTime()
Creates new datetime, using current date and time.
|
OADateTime(Calendar c)
Creates new datetime, using Calendar parameter.
|
OADateTime(Date date)
Creates new datetime, using date parameter.
|
OADateTime(int year,
int month,
int day) |
OADateTime(int year,
int month,
int day,
int hrs,
int mins) |
OADateTime(int year,
int month,
int day,
int hrs,
int mins,
int secs) |
OADateTime(int year,
int month,
int day,
int hrs,
int mins,
int secs,
int milsecs) |
OADateTime(long time)
Creates new datetime, using date parameter.
|
OADateTime(OADate d,
OATime t)
Creates new datetime, using date and time.
|
OADateTime(OADateTime odt)
Creates new datetime, using OADateTime parameter.
|
OADateTime(String strDate)
Creates new datetime, using String parameter.
|
OADateTime(String strDate,
String format)
Creates new datetime, using String parameter and format.
|
OADateTime(Time time)
Creates new datetime, using time parameter.
|
OADateTime(Timestamp date)
Creates new datetime, using timestamp parameter.
|
Modifier and Type | Method and Description |
---|---|
protected GregorianCalendar |
_getCal() |
protected void |
_releaseCal(GregorianCalendar cal) |
OADateTime |
addDay() |
OADateTime |
addDays(int amount)
Return an OADateTime where a specified amount of days is added.
|
static void |
addGlobalParseFormat(String fmt)
Add additional global parse formats that are used when converting a String to OADateTime.
|
OADateTime |
addHours(int amount)
Return an OADateTime where a specified amount of hours is added.
|
OADateTime |
addMilliSeconds(int amount)
Return an OADateTime where a specified amount of milliseconds is added.
|
OADateTime |
addMinutes(int amount)
Return an OADateTime where a specified amount of minutes is added.
|
OADateTime |
addMonths(int amount)
Return an OADateTime where a specified amount of months is added.
|
OADateTime |
addSeconds(int amount)
Return an OADateTime where a specified amount of seconds is added.
|
OADateTime |
addWeeks(int amount)
Return an OADateTime where a specified amount of weeks added.
|
OADateTime |
addYears(int amount)
Return an OADateTime where a specified amount of years is added.
|
boolean |
after(Object obj)
Compares this OADateTime with any object.
|
boolean |
before(Object obj)
Compares this OADateTime with any object.
|
int |
betweenDays(Object obj)
Returns the number of days between this OADateTime and obj.
|
int |
betweenHours(Object obj)
Returns the number of hours betweeen this OADateTime and obj.
|
long |
betweenMilliSeconds(Object obj)
Returns the number of seconds betweeen this OADateTime and obj.
|
int |
betweenMinutes(Object obj)
Returns the number of minutes betweeen this OADateTime and obj.
|
int |
betweenMonths(Object obj)
Returns the number of months betweeen this OADateTime and obj.
|
int |
betweenSeconds(Object obj)
Returns the number of seconds betweeen this OADateTime and obj.
|
int |
betweenYears(Object obj)
Returns the number of years between this OADateTime and obj.
|
void |
clearDate()
sets date to 1/1/1970 (time 0)
|
void |
clearSecondAndMilliSecond() |
void |
clearTime()
Sets hour,minutes and seconds to zero.
|
int |
compare(Object obj) |
int |
compareTo(Object obj)
Compares this object with the specified object for order.
Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. |
protected OADateTime |
convert(Object obj,
boolean bAlways)
Convert an Object to an OADateTime.
|
OADateTime |
convertTo(TimeZone tz)
Convert the current dt to a different tz, and adjusting it's values
|
boolean |
equals(Object obj)
Compares this OADateTime with any object.
|
protected static String |
fixDate(String s)
Internally used to fix a String date.
|
int |
get12Hour() |
int |
get24Hour()
Gets the hour of the day based on 24 hour clock.
|
int |
getAM_PM()
returns Calendar.AM or Calendar.PM
|
Calendar |
getCalendar()
Returns a clone of the calendar used by this object.
|
Date |
getDate()
Returns java.util.Date object that matches this DateTime.
|
int |
getDay() |
int |
getDayOfWeek()
Returns day of week for date.
|
int |
getDayOfYear()
Returns day of year, where Jan 1 is 1.
|
int |
getDaysInMonth()
Returns number of days in this month.
|
String |
getFormat()
get format to use for this OADateTime
|
static String |
getFormat(int type)
Returns the format string to use for system format.
|
static String |
getFormat(int type,
Locale locale)
Returns the format string to use for system format.
|
protected static SimpleDateFormat |
getFormatter() |
static String |
getGlobalOutputFormat()
Gets the default global format used when converting OADateTime to String.
|
int |
getHour()
Gets the hour of the day based on 24 hour clock.
|
int |
getMilliSecond()
Return value of milliseconds.
|
int |
getMinute()
Return value of minutes.
|
int |
getMonth()
Get month, values between 0-11.
|
int |
getSecond()
Return value of seconds.
|
long |
getTime()
Time as milliseconds, same as Date.getTime()
|
TimeZone |
getTimeZone() |
int |
getWeekOfMonth()
Returns the number of the week within the month, where first week is 1.
|
int |
getWeekOfYear()
Returns number week within the year, where first week is 1.
|
int |
getYear()
Returns year.
|
int |
hashCode() |
boolean |
isAfter(Object obj) |
boolean |
isBefore(Object obj)
Compares this OADateTime with any object.
|
static void |
main(String[] args) |
static void |
removeAllGlobalParseFormats()
Remove a all globally used parse format.
|
static void |
removeGlobalParseFormat(String fmt)
Remove a global parse format.
|
void |
set12Hour(int hr) |
void |
set24Hour(int hr)
Sets the hour of the day based on 24 hour clock.
|
void |
setAM_PM(int ap)
Calendar.AM or Calendar.PM
|
protected void |
setCalendar(Date date) |
protected void |
setCalendar(GregorianCalendar c) |
protected void |
setCalendar(int year,
int month,
int day,
int hrs,
int mins,
int secs,
int milsecs) |
protected void |
setCalendar(OADateTime dt) |
protected void |
setCalendar(String strDate) |
protected void |
setCalendar(String strDate,
String fmt) |
protected void |
setCalendar(Time time) |
protected void |
setCalendar(Timestamp date) |
void |
setDate(int yr,
int m,
int d)
Sets year (ex: 2017), month (0-11), and day (1-31).
|
void |
setDate(OADate d) |
void |
setDay(int d)
Set the day of month, 1-31.
|
void |
setFormat(String fmt)
Set format to use for this OADateTime
This format will be used when converting this datetime to a String, unless
a format is specified when calling toString.
|
static void |
setGlobalOutputFormat(String fmt)
Sets the default global format used when converting OADateTime to String.
|
void |
setHour(int hr)
Sets the hour of the day based on 24 hour clock.
|
static void |
setLocale(Locale loc) |
void |
setMilliSecond(int ms)
Sets value for milliseconds.
|
void |
setMinute(int mins)
Set value for minutes.
|
void |
setMonth(int month)
Set month, values between 0-11.
|
void |
setSecond(int s)
Sets value for seconds.
|
void |
setTime(int hr,
int m)
Sets time.
|
void |
setTime(int hr,
int m,
int s)
Sets time.
|
void |
setTime(int hr,
int m,
int s,
int ms)
Sets hour,minutes,seconds and milliseconds.
|
void |
setTime(OATime t) |
void |
setTimeZone(TimeZone tz)
Change the tz and keep the same other values (day,month,hour,etc).
|
void |
setYear(int y)
Sets the year.
|
static void |
test(int id) |
String |
toString()
Converts OADateTime to a String using specified formatting String.
Uses the first format that has been set: "format", "staticOutputFormat" else or "yyyy-MMM-dd hh:mma" |
String |
toString(String f)
Converts OADateTime to a String using specified formatting String.
|
protected String |
toStringMain(String format) |
static OADateTime |
valueOf(String strDateTime)
Converts a String date to an OADateTime.
|
static OADateTime |
valueOf(String strDateTime,
String fmt)
Static method for converting a String date to an OADateTime.
If date is " " (space) then todays date will be returned. If date is null or "" then null is returned. |
protected static Date |
valueOfMain(String value,
String inputFormat,
Vector vec,
String outputFormat) |
public static final String FORMAT_long
protected long _time
protected TimeZone timeZone
protected String format
protected static String staticOutputFormat
public OADateTime()
public OADateTime(Time time)
public OADateTime(Date date)
public OADateTime(long time)
public OADateTime(Timestamp date)
public OADateTime(Calendar c)
public OADateTime(OADateTime odt)
public OADateTime(String strDate)
valueOf(String)
public OADateTime(String strDate, String format)
valueOf(String)
public OADateTime(int year, int month, int day)
year
- full year (not year minus 1900 like Date)month
- 0-11day
- day of the monthpublic OADateTime(int year, int month, int day, int hrs, int mins)
public OADateTime(int year, int month, int day, int hrs, int mins, int secs)
public OADateTime(int year, int month, int day, int hrs, int mins, int secs, int milsecs)
year
- full year (not year minus 1900 like Date)month
- 0-11day
- day of the monthprotected GregorianCalendar _getCal()
protected void _releaseCal(GregorianCalendar cal)
public static void setLocale(Locale loc)
public Calendar getCalendar()
protected void setCalendar(int year, int month, int day, int hrs, int mins, int secs, int milsecs)
protected void setCalendar(GregorianCalendar c)
protected void setCalendar(Timestamp date)
protected void setCalendar(Date date)
protected void setCalendar(Time time)
protected void setCalendar(OADateTime dt)
protected void setCalendar(String strDate)
public void clearTime()
public void clearDate()
public void setTime(int hr, int m)
setTime
public void setTime(int hr, int m, int s)
setTime
public void setTime(int hr, int m, int s, int ms)
public void setTime(OATime t)
public void setDate(int yr, int m, int d)
public void setDate(OADate d)
public int getYear()
public void setYear(int y)
public int getMonth()
public void setMonth(int month)
month
- must be between 0-11.public int getDay()
public void setDay(int d)
public void setTimeZone(TimeZone tz)
public TimeZone getTimeZone()
public int getHour()
get12Hour()
,
get24Hour()
,
getAM_PM()
public void setHour(int hr)
hr
- is the Hour 0-12setAM_PM(int)
,
set12Hour(int)
,
set24Hour(int)
public int get12Hour()
public void set12Hour(int hr)
public int get24Hour()
setAM_PM(int)
,
setHour(int)
public void set24Hour(int hr)
hr
- is the Hour 0-23setAM_PM(int)
,
setHour(int)
public int getAM_PM()
public void setAM_PM(int ap)
public int getMinute()
public void setMinute(int mins)
public int getSecond()
public void setSecond(int s)
public void clearSecondAndMilliSecond()
public int getMilliSecond()
public void setMilliSecond(int ms)
public Date getDate()
public int getDayOfWeek()
Calendar
public int getDayOfYear()
public int getWeekOfMonth()
public int getWeekOfYear()
public int getDaysInMonth()
public boolean equals(Object obj)
equals
in class Object
obj
- Date, OADate, Calendar, String, etc.compareTo(java.lang.Object)
public boolean before(Object obj)
obj
- Date, OADate, Calendar, String, etc.compareTo(java.lang.Object)
public boolean isBefore(Object obj)
obj
- Date, OADate, Calendar, String, etc.compareTo(java.lang.Object)
public boolean after(Object obj)
obj
- Date, OADate, Calendar, String, etc.compareTo(java.lang.Object)
public boolean isAfter(Object obj)
public int compare(Object obj)
public int compareTo(Object obj)
compareTo
in interface Comparable
obj
- Date, OADate, Calendar, Stringpublic OADateTime convertTo(TimeZone tz)
tz
- public OADateTime addDays(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of days to increment/deincrement (negative number).public OADateTime addDay()
public OADateTime addWeeks(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of weeks to increment/deincrement (negative number).public OADateTime addMonths(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of months to increment/deincrement (negative number).public OADateTime addYears(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of years to increment/deincrement (negative number).public OADateTime addHours(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of hours to increment/deincrement (negative number).public OADateTime addMinutes(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of minutes to increment/deincrement (negative number).public OADateTime addSeconds(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of seconds to increment/deincrement (negative number).public OADateTime addMilliSeconds(int amount)
Note: if this is an instanceof OADate or OATime, then the returned object will be the same type.
amount
- number of milliseconds to increment/deincrement (negative number).public int betweenYears(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public int betweenMonths(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public int betweenDays(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public int betweenHours(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public int betweenMinutes(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public int betweenSeconds(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public long betweenMilliSeconds(Object obj)
obj
- Date, OADateTime, Calendar, etc that can be converted to an OADateTime.public long getTime()
protected OADateTime convert(Object obj, boolean bAlways)
public static OADateTime valueOf(String strDateTime, String fmt)
fmt
- format of date. If not valid, then staticParseFormats and staticOutputFormat will be used.setFormat(java.lang.String)
,
to convert a string using global parse strings
public static OADateTime valueOf(String strDateTime)
setFormat(java.lang.String)
,
setGlobalOutputFormat(java.lang.String)
,
see #getGlobalParseFormats
,
valueOf(String,String)
protected static Date valueOfMain(String value, String inputFormat, Vector vec, String outputFormat)
public String toString()
public String toString(String f)
f
- is format to applypublic static void setGlobalOutputFormat(String fmt)
setFormat(java.lang.String)
public static String getGlobalOutputFormat()
setFormat(java.lang.String)
public static void addGlobalParseFormat(String fmt)
setFormat(java.lang.String)
public static void removeGlobalParseFormat(String fmt)
addGlobalParseFormat
public static void removeAllGlobalParseFormats()
addGlobalParseFormat
public void setFormat(String fmt)
OADateTime
,
toString()
public String getFormat()
OADateTime
protected static SimpleDateFormat getFormatter()
public static String getFormat(int type)
type
- DateFormat.SHORT, MEDIUM, LONG, FULL, DEFAULTpublic static String getFormat(int type, Locale locale)
type
- DateFormat.SHORT, MEDIUM, LONG, FULL, DEFAULTpublic static void main(String[] args)
public static void test(int id)
Copyright © 1999–2019 ViaOA. All rights reserved.