|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object triptracker.core.Utils
public class Utils
Miscellaneous utility methods.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static String |
dateToString(Date date)
|
static String |
dateToString(Date date,
String datePattern)
|
static String |
friendlyString(Date date1,
Date date2)
|
static String |
getExtension(String fileName)
Return the file extension of a file. |
static ImageIcon |
getImageIcon(String file)
Retrieve an ImageIcon from a resource file located in the "/resources/" folder. |
static URL |
getResource(String file)
Retrieve an URL for a resource. |
static Date |
parseDate(String dateString)
|
static Date |
parseDate(String dateString,
String datePattern)
|
static double |
round(double number,
int decimals)
Rounds a number according to Math.round(double) with the
specified number of decimals. |
static String |
roundStr(double number,
int decimals)
Rounds a number according to Math.round(double) with the
specified number of decimals and returns a string with the exact number
of decimals. |
static boolean |
strToBool(String string)
Returns a boolean value from a string. |
static boolean |
strToBool(String string,
boolean def)
Returns a boolean value from a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static String getExtension(String fileName)
fileName
- filename to check
public static URL getResource(String file)
file
- resource to retrieve
public static ImageIcon getImageIcon(String file)
file
- resource to retrieve
public static double round(double number, int decimals)
Math.round(double)
with the
specified number of decimals. It also works to set decimals to a negative
number to round down to whole hundreds, thousands, etc.
number
- number to rounddecimals
- number of decimals to preserve
public static String roundStr(double number, int decimals)
Math.round(double)
with the
specified number of decimals and returns a string with the exact number
of decimals.
number
- number to rounddecimals
- number of decimals to preserve
public static Date parseDate(String dateString)
public static Date parseDate(String dateString, String datePattern)
public static String dateToString(Date date)
public static String dateToString(Date date, String datePattern)
public static String friendlyString(Date date1, Date date2)
public static boolean strToBool(String string)
strToBool(String, boolean)
with the
default value set to false.
string
- string with the integer to parse
NumberFormatException
- if the string is bogusstrToBool(String, boolean)
public static boolean strToBool(String string, boolean def)
string
- string with the integer to parsedef
- default value if the value is neither 0 nor 1.
NumberFormatException
- if the string is bogusstrToBool(String, boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |