MCPcopy Create free account
hub / github.com/Exrick/xpay / StringUtils

Class StringUtils

xpay-code/src/main/java/cn/exrick/common/utils/StringUtils.java:16–110  ·  view source on GitHub ↗

@author Exrickx

Source from the content-addressed store, hash-verified

14 * @author Exrickx
15 */
16public class StringUtils {
17
18 private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
19
20 /**
21 * 格式化 日期 yyyy-MM-dd HH:mm:ss
22 * @param date
23 * @return
24 */
25 public static String getTimeStamp(Date date){
26 if(date == null){
27 return dateFormat.format(new Date());
28 } else {
29 return dateFormat.format(date);
30 }
31 }
32
33 /**
34 * 格式化 日期 yyyy-MM-dd HH:mm:ss
35 * @param time
36 * @return
37 */
38 public static Date getDate(String time){
39
40 try {
41 return dateFormat.parse(time);
42 } catch (ParseException e) {
43 e.printStackTrace();
44 }
45 return new Date();
46 }
47
48 /**
49 * 判断字符创是否为空
50 * @param str
51 * @return
52 */
53 public static boolean isBlank(String str) {
54 int strLen;
55 if (str != null && (strLen = str.length()) != 0) {
56 for(int i = 0; i < strLen; ++i) {
57 if (!Character.isWhitespace(str.charAt(i))) {
58 return false;
59 }
60 }
61
62 return true;
63 } else {
64 return true;
65 }
66 }
67
68 /**
69 * 判断字符创是否为空
70 * @param str
71 * @return
72 */
73 public static boolean isNotBlank(String str) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected