|
Diamond Control Suite 3.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object diamondedge.util.DateTime
public class DateTime
Utility functions to manipulate Date and Calendar objects
Field Summary | |
---|---|
static Date |
EmptyDate
|
static int |
USE_SYSTEM_DAY_OF_WEEK
|
Constructor Summary | |
---|---|
DateTime()
|
Method Summary | |
---|---|
static Date |
add(Date date1,
Date date2)
|
static Date |
add(Date date1,
double daysToAdd)
Returns a date the specified, daysToAdd, number of days after the date, date1 |
static Date |
add(int field,
int number,
Date date)
Returns a date to which a specified time field has been added |
static Date |
add(String interval,
int number,
Date date)
Returns a date to which a specified time interval has been added |
static int |
compare(Date date1,
Date date2)
returns 0 if date1 is the same date as date2 returns 1 if date1 is after (greater than) date2 returns -1 if date1 is before (less than) date2 |
static int |
datePart(String interval,
Date date)
Returns a specified part of the given date |
static int |
datePart(String interval,
Date date,
int firstDayOfWeek,
int FirstWeekOfYear)
Returns a specified part of the given date |
static Date |
dateSerial(int year,
int month,
int day)
|
static int |
day(Date date)
Returns a whole number representing the day of the week |
static int |
dayOfYear(Date date)
Returns a whole number representing the day of the year |
static double |
diff(Date date1,
Date date2)
Returns a double representing the fractional number of days between the two dates. |
static int |
diff(String interval,
Date date1,
Date date2)
Returns the number of time intervals between two dates. |
static int |
diff2(Date date1,
Date date2,
String interval)
Returns the number of time intervals between two dates. |
static String |
format(Date d)
Returns an expression formatted as a date and/or time. |
static String |
format(Date d,
String format)
|
static String |
format(Date d,
String format,
int firstDayOfWeek)
returns the formated string for the given date. |
static String |
format(String dateToParse,
String format)
|
static String |
format(Variant expr,
String format)
|
static String |
formatDateTime(Date d)
Deprecated. |
static Calendar |
getCalendar(Date date)
|
static int |
hour(Date date)
Returns a whole number representing the hour of the day |
static int |
minute(Date date)
Returns a whole number representing the minute |
static int |
month(Date date)
Returns a whole number representing the month |
static String |
monthName(int Month,
boolean Abbreviate)
Returns localized month name |
static Date |
now()
Returns the current system date and time |
static int |
second(Date date)
Returns a whole number representing the second |
static void |
setDefaultDateFormat(DateFormat f)
Sets the default format used to convert dates to strings when only the date portion is set. |
static void |
setDefaultDateTimeFormat(DateFormat f)
Sets the default format used to convert dates to strings when the date and time portions are set. |
static void |
setDefaultTimeFormat(DateFormat f)
Sets the default format used to convert dates to strings when only the time portion is set. |
static Date |
subtract(Date date1,
double daysToSubtract)
Returns a date the specified, daysToSubtract, number of days before the date, date1 |
static float |
timer()
Returns the number of seconds elapsed since midnight |
static Date |
timeSerial(int hour,
int minute,
int second)
Returns a date containing the time for a specific hour, minute and second |
static Date |
toDate(double dbl)
returns a date for the given day since Dec 30, 1899 Note: the fractional part represents the time of day in relation to current timezone. |
static Date |
toDate(String str)
|
static Date |
toDate2(String str)
|
static double |
toDouble(Date date)
returns a double representing the number of days since Dec 30, 1899 Note: the fractional part represents the time of day in relation to current timezone. |
static int |
toInt(Date date)
returns an integer representing the number of days since Dec 30, 1899 |
static int |
weekday(Date date,
int firstDayOfWeek)
Returns a whole number representing the day of the week |
static int |
weekday2(Date date,
int returnType)
Returns the day of the week corresponding to a date. |
static String |
weekdayName(int Weekday,
boolean Abbreviate,
int firstDayOfWeek)
Returns localized weekday name |
static int |
weekOfYear(Date date,
int firstDayOfWeek)
Returns the week of the year corresponding to a date. |
static int |
year(Date date)
Returns a whole number representing the year |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int USE_SYSTEM_DAY_OF_WEEK
public static final Date EmptyDate
Constructor Detail |
---|
public DateTime()
Method Detail |
---|
public static final Calendar getCalendar(Date date)
public static final int compare(Date date1, Date date2)
public static final int toInt(Date date)
public static final double toDouble(Date date)
public static final Date toDate(double dbl)
public static final Date toDate(String str) throws ParseException
ParseException
public static final Date toDate2(String str)
public static Date now()
public static Date add(String interval, int number, Date date)
public static Date add(int field, int number, Date date)
public static Date add(Date date1, Date date2)
public static Date add(Date date1, double daysToAdd)
public static Date subtract(Date date1, double daysToSubtract)
public static int diff(String interval, Date date1, Date date2)
interval
- ---------------
Interval Description
yyyy Returns the number of years.
q Returns the number of quarters.
m Returns the number of months.
y Returns the number of days.
d Returns the number of days.
w Returns the number of days.
ww Returns the number of weeks.
h Returns the number of hours.
n Returns the number of minutes.
s Returns the number of seconds.
public static int diff2(Date date1, Date date2, String interval)
interval
- ---------------
Interval Description
y Returns the number of years.
m Returns the number of months.
d Returns the number of days.
ym Returns the number of months (day and year ignored).
yd Returns the number of days (year ignored).
md Returns the number of days (month and year ignored).
public static double diff(Date date1, Date date2)
public static int year(Date date)
public static int month(Date date)
public static int day(Date date)
public static int dayOfYear(Date date)
public static int weekday(Date date, int firstDayOfWeek)
firstDayOfWeek
- 0 means use default calendar, otherwise use Calendar constants such as Calendar.SUNDAYpublic static int weekday2(Date date, int returnType)
date
- date to extract the day of week from.returnType
- One of: 0
- returns day for default calendar
1
- returns 1 (Sunday) through 7 (Saturday)
2
- returns 1 (Monday) through 7 (Sunday)
3
- returns 0 (Monday) through 6 (Sunday)
public static int weekOfYear(Date date, int firstDayOfWeek)
date
- date to extract the day of week from.firstDayOfWeek
- One of: 0
- returns week for default calendar
1
- week begins on Sunday
2
- week begins on Monday
public static int hour(Date date)
public static int minute(Date date)
public static int second(Date date)
public static float timer()
public static Date dateSerial(int year, int month, int day)
public static Date timeSerial(int hour, int minute, int second)
public static int datePart(String interval, Date date, int firstDayOfWeek, int FirstWeekOfYear)
public static int datePart(String interval, Date date)
public static String formatDateTime(Date d)
public static String format(Date d)
public static void setDefaultDateFormat(DateFormat f)
format(java.util.Date)
public static void setDefaultTimeFormat(DateFormat f)
format(java.util.Date)
public static void setDefaultDateTimeFormat(DateFormat f)
format(java.util.Date)
public static String weekdayName(int Weekday, boolean Abbreviate, int firstDayOfWeek)
public static String monthName(int Month, boolean Abbreviate)
public static String format(Date d, String format, int firstDayOfWeek)
Note: Make sure you change N to m, Nn to mm, m to M, mm to MM and mmm to MMM Note: You should change your VB code for user-defined formats to use the codes underneath the Java column. All but the E, EEEE, and a will also work the same in VB. Named Date/Time Formats ----------------------- General Date Display a date and/or time. For real numbers, display a date and time, for example, 4/3/93 05:34 PM.If there is no fractional part, display only a date, for example, 4/3/93. If there is no integer part, display time only, for example, 05:34 PM. Date display is determined by your system settings. Long Date Display a date according to your system's long date format. Medium Date Display a date using the medium date format appropriate for the language version of thehost application. Short Date Display a date using your system's short date format. Long Time Display a time using your system's long time format; includes hours, minutes, seconds. Medium Time Display time in 12-hour format using hours and minutes and the AM/PM designator. Short Time Display a time using the 24-hour format, for example, 17:45. User-defined Date/Time Formats ------------------------------ VB Java Description (:) Time separator. In somelocales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings. (/) Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings. c Display the date as ddddd and display the time as ttttt, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion. d d Display the day as a number without a leading zero (1 to 31). dd dd Display the day as a number with a leading zero (01 to 31). ddd E Display the day as an abbreviation (Sun to Sat). dddd EEEE Display the day as a full name (Sunday to Saturday). ddddd Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. The default short date format is m/d/yy. dddddd Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. The default long date format is mmmm dd, yyyy. w Display the day of the week as a number (1 for Sunday through 7 for Saturday). ww w Display the week of the year as a number (1 to 54). m M Display the month as a number without a leading zero (1 to 12). If m immediately follows h or hh, the minute rather than the month is displayed. mm MM Display the month as a number with a leading zero (01 to 12). If m immediately follows h or hh, the minute rather than the month is displayed. mmm MMM Display the month as an abbreviation (Jan to Dec). mmmm MMMM Display the month as a full month name (January to December). q Display the quarter of the year as a number (1 to 4). y D Display the day of the year as a number (1 to 366). yy yy Display the year as a 2-digit number (00 to 99). yyyy yyyy Display the year as a 4-digit number (100 to 9999). h h Display the hour as a number without leading zeros (0 to 12). Hh hh Display the hour as a number with leading zeros (00 to 12). h H Display the hour as a number without leading zeros (0 to 23). Hh HH Display the hour as a number with leading zeros (00 to 23). N m Display the minute as a number without leading zeros (0 to 59). Nn mm Display the minute as a number with leading zeros (00 to 59). S s Display the second as a number without leading zeros (0 to 59). Ss ss Display the second as a number with leading zeros (00 to 59). ttttt Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The default time format is h:mm:ss. AM/PM a Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M. am/pm a Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M. A/P a Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M. a/p a Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M. AMPM a Use the 12-hour clock and display the AMstring literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. The default format is AM/PM.
public static String format(Date d, String format)
format( Date d, String format, int firstDayOfWeek )
public static String format(String dateToParse, String format)
format( Date d, String format, int firstDayOfWeek )
public static String format(Variant expr, String format)
format( Date d, String format, int firstDayOfWeek )
|
Diamond Control Suite 3.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |