|
Compiere 3.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.compiere.util.TimeUtil
public class TimeUtil
Time Utilities
| Field Summary | |
|---|---|
static String |
TRUNC_DAY
Truncate Day - D |
static String |
TRUNC_MONTH
Truncate Month - MM |
static String |
TRUNC_QUARTER
Truncate Quarter - Q |
static String |
TRUNC_WEEK
Truncate Week - W |
static String |
TRUNC_YEAR
Truncate Year - Y |
| Constructor Summary | |
|---|---|
TimeUtil()
|
|
| Method Summary | |
|---|---|
static Timestamp |
addDays(Timestamp day,
int offset)
Return Day + offset (truncates) |
static Timestamp |
addMinutess(Timestamp dateTime,
int offset)
Return DateTime + offset in minutes |
static String |
formatElapsed(long elapsedMS)
Format Elapsed Time |
static String |
formatElapsed(Timestamp start)
Format Elapsed Time until now |
static String |
formatElapsed(Timestamp start,
Timestamp end)
Format Elapsed Time |
static Timestamp |
getDay(int year,
int month,
int day)
Get earliest time of a day (truncate) |
static Timestamp |
getDay(long time)
Get earliest time of a day (truncate) |
static Timestamp |
getDay(Timestamp dayTime)
Get earliest time of a day (truncate) |
static int |
getDaysBetween(Timestamp start,
Timestamp end)
Calculate the number of days between start and end. |
static Timestamp |
getDayTime(Timestamp day,
Timestamp time)
Return the day and time |
static Timestamp |
getMonthLastDay(Timestamp day)
Get last date in month |
static Timestamp |
getNextDay(Timestamp day)
Get earliest time of next day |
static Calendar |
getToday()
Get today (truncate) |
static boolean |
inRange(Timestamp start,
Timestamp end,
boolean OnMonday,
boolean OnTuesday,
boolean OnWednesday,
boolean OnThursday,
boolean OnFriday,
boolean OnSaturday,
boolean OnSunday)
Is start..end on one of the days ? |
static boolean |
inRange(Timestamp start_1,
Timestamp end_1,
Timestamp start_2,
Timestamp end_2)
Is the _1 in the Range of _2 Time_1 +--x--+ Time_2 +a+ +---b---+ +c+ The function returns true for b and false for a/b. |
static boolean |
isAllDay(Timestamp start,
Timestamp end)
Is all day |
static boolean |
isSameDay(Timestamp one,
Timestamp two)
Is it the same day |
static boolean |
isSameHour(Timestamp one,
Timestamp two)
Is it the same hour |
static boolean |
isValid(Timestamp validFrom,
Timestamp validTo)
Is it valid today? |
static boolean |
isValid(Timestamp validFrom,
Timestamp validTo,
Timestamp testDate)
Is it valid on test date |
static void |
main(String[] args)
Test |
static Timestamp |
max(Timestamp ts1,
Timestamp ts2)
Max date |
static Timestamp |
trunc(Timestamp dayTime,
String trunc)
Get truncated day/time |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String TRUNC_DAY
public static final String TRUNC_WEEK
public static final String TRUNC_MONTH
public static final String TRUNC_QUARTER
public static final String TRUNC_YEAR
| Constructor Detail |
|---|
public TimeUtil()
| Method Detail |
|---|
public static Timestamp getDay(long time)
time - day and time
public static Timestamp getDay(Timestamp dayTime)
dayTime - day and time
public static Timestamp getDay(int year,
int month,
int day)
day - day 1..31month - month 1..12year - year (if two digits: < 50 is 2000; > 50 is 1900)
public static Calendar getToday()
public static Timestamp getNextDay(Timestamp day)
day - day
public static Timestamp getMonthLastDay(Timestamp day)
day - day
public static Timestamp getDayTime(Timestamp day,
Timestamp time)
day - day parttime - time part
public static boolean inRange(Timestamp start_1,
Timestamp end_1,
Timestamp start_2,
Timestamp end_2)
Time_1 +--x--+
Time_2 +a+ +---b---+ +c+
The function returns true for b and false for a/b.
start_1 - start (1)end_1 - not included end (1)start_2 - start (2)end_2 - not included (2)
public static boolean inRange(Timestamp start,
Timestamp end,
boolean OnMonday,
boolean OnTuesday,
boolean OnWednesday,
boolean OnThursday,
boolean OnFriday,
boolean OnSaturday,
boolean OnSunday)
start - start dayend - end day (not including)OnMonday - true if OKOnTuesday - true if OKOnWednesday - true if OKOnThursday - true if OKOnFriday - true if OKOnSaturday - true if OKOnSunday - true if OK
public static boolean isSameDay(Timestamp one,
Timestamp two)
one - daytwo - compared day
public static boolean isSameHour(Timestamp one,
Timestamp two)
one - day/timetwo - compared day/time
public static boolean isAllDay(Timestamp start,
Timestamp end)
start - start dateend - end date
public static int getDaysBetween(Timestamp start,
Timestamp end)
start - start dateend - end date
public static Timestamp addDays(Timestamp day,
int offset)
day - Dayoffset - day offset
public static Timestamp addMinutess(Timestamp dateTime,
int offset)
dateTime - Date and Timeoffset - minute offset
public static String formatElapsed(Timestamp start,
Timestamp end)
start - start time or null for nowend - end time or null for now
public static String formatElapsed(Timestamp start)
start - start time
public static String formatElapsed(long elapsedMS)
elapsedMS - time in ms
public static boolean isValid(Timestamp validFrom,
Timestamp validTo)
validFrom - valid fromvalidTo - valid to
public static boolean isValid(Timestamp validFrom,
Timestamp validTo,
Timestamp testDate)
validFrom - valid fromvalidTo - valid totestDate - Date
public static Timestamp max(Timestamp ts1,
Timestamp ts2)
ts1 - p1ts2 - p2
public static Timestamp trunc(Timestamp dayTime,
String trunc)
dayTime - daytrunc - how to truncate TRUNC_*
public static void main(String[] args)
args - ignored
|
Compiere 3.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||