|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.jfimagine.utils.commonutil.CommonUtil
Common utilities for data converting, datetime processing and others.
| Constructor Summary | |
CommonUtil()
|
|
| Method Summary | |
static java.lang.String |
appendStr(java.lang.String str,
boolean headChar,
char ch,
int len)
Continuous add a letter at the begining/end of a String, untill the length of the String equals to len |
static int |
b2i(boolean b)
Convert a boolean value to an int one |
static java.lang.String |
byteToHex(byte[] byteAry)
Convert a byte array to a 2-chars hex string |
static boolean |
chkValidInt(java.lang.Integer i)
Check if an Integer object value has valid or invalid value |
static boolean |
chkValidStr(java.lang.String s)
Check if an String value has valid or invalid value |
static java.lang.String |
d2s(java.util.Date d)
Convert a date to String |
static java.lang.String |
dt2s(java.util.Date d)
Convert a datetime to String |
static java.lang.String |
f2fs(double d)
Format a double value to string |
static java.lang.String |
f2fs(double d,
int scale)
Format a double value to string |
static java.lang.String |
f2s(double d)
Convert a double value to a string |
static java.util.Date |
firstDayOfTheMonth(java.util.Date d)
Get the first Day of a month which the date exists |
static java.util.Date |
firstDayOfTheYear(java.util.Date d)
Get the first Day of a year which the date exists |
static java.util.Date |
firstDayOfThisMonth()
Get the first Day of this month |
static java.util.Date |
firstDayOfThisYear()
Get the first day of this Year |
static java.lang.String |
format(double d,
int precision,
int scale)
Format a double value to string |
static int |
getCharCount(java.lang.String inputStr,
char ch)
Find the number of a char that occurs in the string. |
static java.util.Date |
getDate(java.util.Date curDate,
int offset)
Increase or decrease date by offset |
static java.util.Date |
getDate(int year,
int month,
int day)
Encode date from Year,Month and Day |
static int |
getDay(java.util.Date d)
Get the day part from a date |
static int |
getHour(java.util.Date d)
Get the hour part from a date |
static int |
getMillisecond(java.util.Date d)
Get the millisecond part from a date |
static int |
getMinute(java.util.Date d)
Get the minute part from a date |
static int |
getMonth(java.util.Date d)
Get the month part from a date |
static int |
getSecond(java.util.Date d)
Get the second part from a date |
static java.lang.String |
getSystemProperty(java.lang.String inKey)
Get a system property by a key. |
static int |
getYear(java.util.Date d)
Get the year part from a date |
static byte[] |
hexToByte(java.lang.String hexStr)
Convert a hex string to a byte array. |
static java.lang.String |
hexToStr(java.lang.String hexStr)
Convert a 2-chars hex string to a normal string |
static boolean |
i2b(int i)
Convert an int value to a boolean one |
static java.lang.String |
i2s(int i)
Convert an int value to String |
static java.lang.String |
i2s(java.lang.Integer i)
Convert an Integer object value to String |
static boolean |
isURLFile(java.lang.String fileName)
Check if a specified file name is a URL file name |
static java.util.Date |
lastDayOfTheMonth(java.util.Date d)
Get the last Day of a month which the date exists |
static java.util.Date |
lastDayOfTheYear(java.util.Date d)
Get the last day of a year which the date exists |
static java.util.Date |
lastDayOfThisMonth()
Get the last Day of this month |
static java.util.Date |
lastDayOfThisYear()
Get the last day of this Year |
static char |
newLine()
return a netLine() letter (not all platforms use '\n' for a newline) |
static java.util.Date |
now_date()
Get system's current date |
static java.util.Date |
now_time()
Get system's current time |
static java.util.Date |
now()
Get system's current datetime |
static java.lang.String |
o2s(java.lang.Object o)
Convert an object to a string |
static java.util.Date |
s2d(java.lang.String s)
Convert a string to a date value |
static java.util.Date |
s2dt(java.lang.String s)
Convert a string to a datetime value |
static double |
s2f(java.lang.String s)
Convert a String to a double value |
static int |
s2i(java.lang.String s)
Convert a String to an int value |
static java.util.Date |
s2t(java.lang.String s)
Convert a string to a time value |
static java.lang.String |
strToHex(java.lang.String str)
Convert a normal string to a a 2-chars hex string |
static java.lang.String |
t2s(java.util.Date d)
Convert a time to String |
static java.lang.String |
validChnStr(java.lang.String str)
Correct problems in Chinese letters |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CommonUtil()
| Method Detail |
public static boolean isURLFile(java.lang.String fileName)
fileName - The file name to be checked.public static char newLine()
public static int getCharCount(java.lang.String inputStr,
char ch)
inputStr - An input string to be measured.ch - A char to be found.
public static java.lang.String validChnStr(java.lang.String str)
str - String to be corrected
public static java.lang.String appendStr(java.lang.String str,
boolean headChar,
char ch,
int len)
str - String to be expendheadChar - Adding chars at begining or end of a stringch - Character to be added
public static java.lang.String strToHex(java.lang.String str)
str - Original string.
public static java.lang.String hexToStr(java.lang.String hexStr)
hexStr - Original hexstring.
public static java.lang.String byteToHex(byte[] byteAry)
byteAry - the byte array
public static byte[] hexToByte(java.lang.String hexStr)
hexStr - The hex string.
public static java.util.Date now()
public static java.util.Date now_date()
public static java.util.Date now_time()
public static java.util.Date firstDayOfTheYear(java.util.Date d)
d - the date within a year
public static java.util.Date lastDayOfTheYear(java.util.Date d)
d - the date within a year
public static java.util.Date firstDayOfThisYear()
public static java.util.Date lastDayOfThisYear()
public static java.util.Date firstDayOfTheMonth(java.util.Date d)
d - the date within a month
public static java.util.Date lastDayOfTheMonth(java.util.Date d)
d - the date within a month
public static java.util.Date firstDayOfThisMonth()
public static java.util.Date lastDayOfThisMonth()
public static java.util.Date getDate(int year,
int month,
int day)
year - the Year part of a datemonth - the Month part of a dateday - the Day part of a date
public static java.util.Date getDate(java.util.Date curDate,
int offset)
curDate - the date value to be increased or decreasedoffset - the number of days, be negative value if decrease.
public static int getYear(java.util.Date d)
d - A date value to be extracted
public static int getMonth(java.util.Date d)
d - A date value to be extracted
public static int getDay(java.util.Date d)
d - A date value to be extracted
public static int getHour(java.util.Date d)
d - A date value to be extracted
public static int getMinute(java.util.Date d)
d - A date value to be extracted
public static int getSecond(java.util.Date d)
d - A date value to be extracted
public static int getMillisecond(java.util.Date d)
d - A date value to be extracted
public static java.lang.String d2s(java.util.Date d)
d - A date value to be converted
public static java.lang.String t2s(java.util.Date d)
d - A time value to be converted
public static java.lang.String dt2s(java.util.Date d)
d - A datetime value to be converted
public static java.util.Date s2d(java.lang.String s)
s - A string formatted as 'YYYY-MM-DD', represents a date value
public static java.util.Date s2t(java.lang.String s)
s - A string formatted as 'hh:mm:ss', represents a time value
public static java.util.Date s2dt(java.lang.String s)
s - A string formatted as 'YYYY-MM-DD hh:mm:ss', represents a datetime value
public static int b2i(boolean b)
b - a boolean value to be converted
public static boolean i2b(int i)
i - an int value to be converted
public static int s2i(java.lang.String s)
s - a string to be converted
public static java.lang.String i2s(int i)
i - an int value to be converted
public static java.lang.String i2s(java.lang.Integer i)
i - an Integer object value to be converted
public static double s2f(java.lang.String s)
s - a string to be converted
public static java.lang.String f2s(double d)
d - a double value to be converted
public static java.lang.String o2s(java.lang.Object o)
o - an object to be converted
public static java.lang.String format(double d,
int precision,
int scale)
throws java.lang.Exception
d - a double value to be formattedprecision - a precision for length of all digitsscale - digits count of the fraction partition
java.lang.Exceptionpublic static java.lang.String f2fs(double d)
d - a double value to be formatted
public static java.lang.String f2fs(double d,
int scale)
d - a double value to be formattedscale - digits count of the fraction partition
public static boolean chkValidInt(java.lang.Integer i)
i - an Integer object to be checked
public static boolean chkValidStr(java.lang.String s)
s - a String to be checked
public static java.lang.String getSystemProperty(java.lang.String inKey)
inKey - A system property key.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||