Subversion Repositories SmartDukaan

Rev

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

Rev 22470 Rev 22858
Line 15... Line 15...
15
import org.slf4j.Logger;
15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
16
import org.slf4j.LoggerFactory;
17
 
17
 
18
import com.fasterxml.jackson.core.JsonProcessingException;
18
import com.fasterxml.jackson.core.JsonProcessingException;
19
import com.fasterxml.jackson.databind.ObjectMapper;
19
import com.fasterxml.jackson.databind.ObjectMapper;
-
 
20
import com.spice.profitmandi.common.enumuration.DateTimePattern;
20
 
21
 
21
public class StringUtils {
22
public class StringUtils {
22
	
23
	
23
	private static ObjectMapper objectMapper = new ObjectMapper();
24
	private static ObjectMapper objectMapper = new ObjectMapper();
24
	
25
	
Line 40... Line 41...
40
		return Instant.ofEpochMilli(epocTime).atZone(ZoneId.systemDefault()).toLocalDateTime();
41
		return Instant.ofEpochMilli(epocTime).atZone(ZoneId.systemDefault()).toLocalDateTime();
41
	}
42
	}
42
	
43
	
43
	public static final String toString(LocalDate localDate){
44
	public static final String toString(LocalDate localDate){
44
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
45
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
45
		String formattedDateTime = localDate.format(formatter); // "1986-04-08 12:30"
46
		String formattedDateTime = localDate.format(formatter);
46
		return formattedDateTime;
47
		return formattedDateTime;
47
	}
48
	}
48
	
49
	
49
	public static final LocalDateTime toDateTime(String dateTimeString) throws DateTimeParseException{
50
	public static final LocalDateTime toDateTime(String dateTimeString) throws DateTimeParseException{
50
		if(dateTimeString == null || dateTimeString.equals("0") || dateTimeString.isEmpty()){
51
		if(dateTimeString == null || dateTimeString.equals("0") || dateTimeString.isEmpty()){
51
			return null;
52
			return null;
52
		}
53
		}
53
		LocalDateTime date =
54
		return LocalDateTime.parse(dateTimeString);
-
 
55
	}
-
 
56
	
54
				  Instant.ofEpochMilli(Long.valueOf(dateTimeString))
57
	public static final LocalDateTime toDateTime(String dateTimeString, DateTimePattern dateTimePattern) throws DateTimeParseException{
55
				  .atZone(ZoneId.systemDefault())
58
		if(dateTimeString == null || dateTimeString.equals("0") || dateTimeString.isEmpty()){
56
				  .toLocalDateTime();
-
 
57
		return date;
59
			return null;
-
 
60
		}
-
 
61
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateTimePattern.getValue());
-
 
62
		return LocalDateTime.parse(dateTimeString, formatter);
58
	}
63
	}
59
 
64
 
60
	public static boolean isValidMobile(String mobile){
65
	public static boolean isValidMobile(String mobile){
61
		try{
66
		try{
62
			Long.valueOf(mobile);
67
			Long.valueOf(mobile);