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 Details

  • Method Details

    • md5Hash

      public static String md5Hash​(String st)
      Convert String to its md5 hash using MessageDigest
      Parameters:
      st - String to be converted to hash
      Returns:
      hashed String
    • checkIC

      public static boolean checkIC​(String icNo)
      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

      public static boolean checkPhoneNo​(String phoneNo)
      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

      public static boolean checkPassword​(String password)
      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

      public static boolean checkEmail​(String email)
      Check if email is valid
      Parameters:
      email - email adress in String
      Returns:
      true if email is valid, false if otherwise
    • stringToDate

      public static Date stringToDate​(String date)
      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

      public static long daysDifference​(Date date1, Date date2)
      Calculate the date difference between 2 java date object
      Parameters:
      date1 - java.util.Date object
      date2 - java.util.Date object
      Returns:
      days difference in long, throw NullPointerException if date1 or date2 is null
    • daysIncrement

      public static LocalDate daysIncrement​(LocalDate date, int increment)
      This method will increment the provided localdate object by specified days
      Parameters:
      date - Localdate object
      increment - days to increment
      Returns:
      LocalDate of the incremented date