Subversion Repositories SmartDukaan

Rev

Rev 21570 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21543 ashik.ali 1
package com.spice.profitmandi.common.util;
2
 
3
import java.time.LocalDate;
4
import java.time.LocalTime;
5
import java.time.format.DateTimeParseException;
6
 
7
import javax.mail.internet.InternetAddress;
8
 
9
public class StringUtils {
10
	private StringUtils(){
11
 
12
	}
13
	public static final LocalDate toDate(String dateString)throws DateTimeParseException{
14
		return LocalDate.parse(dateString);
15
	}
16
 
17
	public static final LocalTime toTime(String timeString) throws DateTimeParseException{
18
		return LocalTime.parse(timeString);
19
	}
20
 
21
	public static boolean isValidMobile(String mobile){
22
		try{
23
			Long.valueOf(mobile);
24
		}
25
		catch(Exception e){
26
			return false;
27
		}
28
 
29
		if (mobile.startsWith("0")){
30
			return false;
31
		}
32
		if (mobile.length()!=10){
33
			return false;
34
		}
35
		return true;
36
	}
37
 
38
	public static boolean isValidEmailAddress(String email) {
39
		boolean result = true;
40
		try {
41
			InternetAddress emailAddr = new InternetAddress(email);
42
			emailAddr.validate();
43
		} catch (Exception ex) {
44
			result = false;
45
		}
46
		return result;
47
	}
48
}