TUYỂN DỤNG

[Programming][Java] String Utility.



Trim space and null.

public static String trim(String str) {
        if (str != null && !str.isEmpty()) {
            String rs = str.trim();
            rs = rs.replaceAll("\\s+", " ");
            return rs;
        }
        return "";
    }

Check string is null or empty.

public static boolean isNulOrEmpty(String value) {
        return value == null || value.trim().isEmpty();
    }

Check string is positive number.

public static boolean isPositiveNumber(String value) {
        if (value != null) {
            value = value.replaceAll("\\s+", "");
            if (!value.isEmpty()) {
                if (value.matches("^[0-9]+$")) {
                    return isNumber(value) && (toBigDecimal(value).longValue() > 0L);
                }
            }
        }
        return true;
    }
    //---------------------
    Check Time (HH:MM): isValidWithPattern(tmpBis, "([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]");
    Check Time (HH:MM:SS): isValidWithPattern(tmpBis, "([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]");

Check validate email address with regular expression.

public static boolean isValidEmailAddress(String email) {
        if (email != null) {
            email = email.replaceAll("\\s+", "");
            if (!email.isEmpty()) {
                String ePattern = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
                java.util.regex.Pattern p = java.util.regex.Pattern.compile(ePattern);
                java.util.regex.Matcher m = p.matcher(email);
                return m.matches();
            }
        }
        return true;
    }

Check validate string with regular expression.

public static boolean isValidWithPattern(String value, String pattern) {
        if (value != null) {
            if (!value.isEmpty()) {
                java.util.regex.Pattern p = java.util.regex.Pattern.compile(pattern);
                java.util.regex.Matcher m = p.matcher(value);
                return m.matches();
            }
        }
        return true;
    } 



--------------------

--------------------

COMMENTS

Name

Anime,1,Application,6,Articles,6,Audio,2,Database,4,ElasticSearch,1,FFmpeg,1,Java,6,JavaScript,1,Links,2,Model,3,MS-SQL,3,Notepad++,1,Pictures,4,Programming,7,Projects,3,SPS,3,SQL,4,System,1,Truyện,2,Windows 10,1,YouTube,1,
ltr
item
Bùi Ngọc Sơn: [Programming][Java] String Utility.
[Programming][Java] String Utility.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhycB7QoBPXSrWt04Nqd_qZ00OEZli8sgsg92_FIIBDoIWoE38llos7MVjgH8dhWItv9aay0aZzrwvyPOWRmgtGXFdlrGPOCgleuq1_wMotWQxlQduOzpvrRsapjUnoWu6QyVuxHP3JT64/s640/Java-String-Utility.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhycB7QoBPXSrWt04Nqd_qZ00OEZli8sgsg92_FIIBDoIWoE38llos7MVjgH8dhWItv9aay0aZzrwvyPOWRmgtGXFdlrGPOCgleuq1_wMotWQxlQduOzpvrRsapjUnoWu6QyVuxHP3JT64/s72-c/Java-String-Utility.png
Bùi Ngọc Sơn
https://bnson1986.blogspot.com/2019/11/java-string-utility.html
https://bnson1986.blogspot.com/
http://bnson1986.blogspot.com/
http://bnson1986.blogspot.com/2019/11/java-string-utility.html
true
7468510552861380973
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content