具体内容
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 
 | import java.text.SimpleDateFormat;import java.util.Calendar;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import 这个是传入数据的封装jar包,可以不用看,具体看自己需求context.Recordset;
 
 public class ApplyUtil {
 public final static String Number_Chinese  =  "1";
 public final static String Number_Point  =  "2";
 
 
 
 
 
 public static boolean isEmpty(String str){
 if(null == str || str.trim().equals("")){
 return true;
 }
 return false;
 }
 
 
 
 
 
 
 public static boolean isRecordsetNull(Recordset rs){
 if(null == rs || rs.size() == 0){
 return true;
 }
 return false;
 }
 
 
 
 
 
 
 
 public static String addMonth(int month){
 Calendar   cal   =   Calendar.getInstance();
 SimpleDateFormat   sFmt   =   new   SimpleDateFormat("yyyy年MM月dd日");
 if   (month   !=   0)   {
 cal.add(Calendar.MONTH,   month);
 }
 return   sFmt.format(cal.getTime());
 }
 
 
 
 
 
 
 
 
 public static String parseDate2String(String date,String style){
 String formatDate = "";
 int len = 0;
 if(!ApplyUtil.isEmpty(date)){
 len = date.trim().length();
 if(len == 8){
 if(Number_Chinese.equals(style)){
 formatDate = getNumberChineseDate(date);
 }
 if(Number_Point.equals(style)){
 formatDate = getNumberPointDate(date);
 }
 }else{
 formatDate = date;
 }
 }
 return formatDate;
 }
 
 
 
 
 
 
 private static String getNumberChineseDate(String date){
 String year = date.substring(0, 4);
 String month = leaveZero(date.substring(4, 6));
 String day = leaveZero(date.substring(6,8));
 return year + "年" + month + "月" + day + "日";
 }
 
 
 
 
 
 
 private static String getNumberPointDate(String date){
 String year = date.substring(0, 4);
 String month = leaveZero(date.substring(4, 6));
 String day = leaveZero(date.substring(6,8));
 return year + "." + month + "." + day;
 }
 
 
 
 
 
 
 private static String leaveZero(String str){
 if(str.length() == 2 && str.charAt(0) == '0'){
 return str.substring(1,2);
 }
 return str;
 }
 
 
 
 
 
 
 
 
 public static String getSuffix(String file) {
 if(isEmpty(file) || file.indexOf(".") == -1 || file.indexOf(".") == file.length() - 1)
 return "";
 System.out.println(file.length());
 System.out.println(file.lastIndexOf("."));
 String suffix=file.substring(file.lastIndexOf("."),file.length());
 return suffix.toLowerCase();
 }
 
 
 
 
 
 
 
 public static boolean isEmail(String email){
 
 
 
 
 
 
 if(email == null){
 return false;
 }
 
 
 
 
 if(email.indexOf("..") != -1){
 return false;
 }
 
 
 int atCharacter = email.indexOf("@");
 if (atCharacter == -1) {
 return false;
 }
 
 
 if(atCharacter > email.lastIndexOf('.') || atCharacter+1 == email.lastIndexOf('.')){
 return false;
 }
 
 
 if (email.endsWith(".") || email.endsWith("@") || email.startsWith(".") || email.startsWith("@")) {
 return false;
 }
 return true;
 
 }
 
 
 
 
 
 
 public static boolean isMobileNO(String mobiles){
 String str = "^1[3|4|5|8][0-9][0-9]{8}$";
 
 Pattern p = Pattern.compile(str);
 Matcher m = p.matcher(mobiles.trim());
 return m.matches();
 }
 
 }
 
 | 
 本作品采用知识共享署名 4.0 中国大陆许可协议进行许可,欢迎转载,但转载请注明来自御前提笔小书童,并保持转载后文章内容的完整。本人保留所有版权相关权利。
 本作品采用知识共享署名 4.0 中国大陆许可协议进行许可,欢迎转载,但转载请注明来自御前提笔小书童,并保持转载后文章内容的完整。本人保留所有版权相关权利。
本文链接:https://royalscholar.cn/2017/03/15/java邮箱校验,手机号校验,格式化日期等等/