Subversion Repositories SmartDukaan

Rev

Rev 21543 | Rev 21652 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21543 Rev 21570
Line 1... Line 1...
1
package com.spice.profitmandi.common.util;
1
package com.spice.profitmandi.common.util;
2
 
2
 
3
import java.time.LocalDate;
3
import java.time.LocalDate;
4
import java.time.LocalTime;
4
import java.time.LocalTime;
5
import java.time.format.DateTimeParseException;
5
import java.time.format.DateTimeParseException;
-
 
6
import java.util.ArrayList;
-
 
7
import java.util.List;
6
 
8
 
7
import javax.mail.internet.InternetAddress;
9
import javax.mail.internet.InternetAddress;
8
 
10
 
-
 
11
import org.slf4j.Logger;
-
 
12
import org.slf4j.LoggerFactory;
-
 
13
 
-
 
14
import com.fasterxml.jackson.core.JsonProcessingException;
-
 
15
import com.fasterxml.jackson.databind.ObjectMapper;
-
 
16
 
9
public class StringUtils {
17
public class StringUtils {
-
 
18
	
-
 
19
	private static ObjectMapper objectMapper = new ObjectMapper();
-
 
20
	
-
 
21
	private static final Logger LOGGER = LoggerFactory.getLogger(StringUtils.class);
-
 
22
	
10
	private StringUtils(){
23
	private StringUtils(){
11
 
24
 
12
	}
25
	}
13
	public static final LocalDate toDate(String dateString)throws DateTimeParseException{
26
	public static final LocalDate toDate(String dateString)throws DateTimeParseException{
14
		return LocalDate.parse(dateString);
27
		return LocalDate.parse(dateString);
Line 43... Line 56...
43
		} catch (Exception ex) {
56
		} catch (Exception ex) {
44
			result = false;
57
			result = false;
45
		}
58
		}
46
		return result;
59
		return result;
47
	}
60
	}
-
 
61
	
-
 
62
	public static List<String> getDuplicateElements(List<String> elements){
-
 
63
		List<String> duplicates = new ArrayList<>();
-
 
64
		for(int i = 0; i < elements.size(); i++){
-
 
65
			for(int j = i + 1; j < elements.size(); j++){
-
 
66
				if(elements.get(i).equals(elements.get(j))){
-
 
67
					duplicates.add(elements.get(i));
-
 
68
				}
-
 
69
			}
-
 
70
		}
-
 
71
		return duplicates;
-
 
72
	}
-
 
73
	
-
 
74
	public static String toString(Object object) throws Exception{
-
 
75
		try {
-
 
76
			return objectMapper.writeValueAsString(object);
-
 
77
		} catch (JsonProcessingException e) {
-
 
78
			LOGGER.error("Error occured while converting object to json", e);
-
 
79
			throw e;
-
 
80
		}
-
 
81
	}
48
}
82
}