Package my.edu.tarc.dco.bookrentalpos
Class CustomUtil
java.lang.Object
my.edu.tarc.dco.bookrentalpos.CustomUtil
public class CustomUtil extends Object
Contains all the custom utilities function
- Version:
- 1.0
- Author:
- Looz
-
Constructor Summary
Constructors Constructor Description CustomUtil() -
Method Summary
Modifier and Type Method Description static booleancheckEmail(String email)Check if email is validstatic booleancheckIC(String icNo)Checks if NRIC fits the Malaysia's IC Standard
Note that icNo given must not contain '-'static booleancheckPassword(String password)Method to check if the password have at least 8 char long, have a number and have a capital letterstatic booleancheckPhoneNo(String phoneNo)Checks if phone number is valid.static longdaysDifference(Date date1, Date date2)Calculate the date difference between 2 java date objectstatic LocalDatedaysIncrement(LocalDate date, int increment)This method will increment the provided localdate object by specified daysstatic Stringmd5Hash(String st)Convert String to its md5 hash using MessageDigeststatic DatestringToDate(String date)Convert date time generated in sqlite database to java date object
-
Constructor Details
-
CustomUtil
public CustomUtil()
-
-
Method Details
-
md5Hash
Convert String to its md5 hash using MessageDigest- Parameters:
st- String to be converted to hash- Returns:
- hashed String
-
checkIC
Checks if NRIC fits the Malaysia's IC Standard
Note that icNo given must not contain '-'- Parameters:
icNo- NRIC in String- Returns:
- True if the NRIC is valid, false if otherwise
-
checkPhoneNo
Checks if phone number is valid.
will check if the number starts with 0- Parameters:
phoneNo- - phone number in String- Returns:
- return true if phone is valid, false if otherwise
-
checkPassword
Method to check if the password have at least 8 char long, have a number and have a capital letter- Parameters:
password- String to check- Returns:
- true if pass, false if other wise
-
checkEmail
Check if email is valid- Parameters:
email- email adress in String- Returns:
- true if email is valid, false if otherwise
-
stringToDate
Convert date time generated in sqlite database to java date object- Parameters:
date- - date in String from database- Returns:
- date object if parsed successfully, null if ParseException was thrown
-
daysDifference
Calculate the date difference between 2 java date object- Parameters:
date1- java.util.Date objectdate2- java.util.Date object- Returns:
- days difference in long, throw NullPointerException if date1 or date2 is null
-
daysIncrement
This method will increment the provided localdate object by specified days- Parameters:
date- Localdate objectincrement- days to increment- Returns:
- LocalDate of the incremented date
-