| Line 37... |
Line 37... |
| 37 |
import java.util.regex.Matcher;
|
37 |
import java.util.regex.Matcher;
|
| 38 |
import java.util.regex.Pattern;
|
38 |
import java.util.regex.Pattern;
|
| 39 |
|
39 |
|
| 40 |
public class Utils {
|
40 |
public class Utils {
|
| 41 |
|
41 |
|
| 42 |
public static final float FLOAT_EPSILON = 0.001f;
|
42 |
public static final float FLOAT_EPSILON = 0.001f;
|
| 43 |
|
43 |
|
| 44 |
public static final double DOUBLE_EPSILON = 0.001d;
|
44 |
public static final double DOUBLE_EPSILON = 0.001d;
|
| 45 |
|
45 |
|
| 46 |
|
46 |
|
| 47 |
public static String[] getAlphaNumericParts(String alphaNumericString) {
|
47 |
public static String[] getAlphaNumericParts(String alphaNumericString) {
|
| 48 |
String[] parts = alphaNumericString.split("(?<=\\D)(?=\\d)");
|
48 |
String[] parts = alphaNumericString.split("(?<=\\D)(?=\\d)");
|
| 49 |
return parts;
|
49 |
return parts;
|
| 50 |
}
|
50 |
}
|
| 51 |
|
51 |
|
| 52 |
private static final Logger logger = LogManager.getLogger(Utils.class);
|
52 |
private static final Logger logger = LogManager.getLogger(Utils.class);
|
| 53 |
public static final String EXPORT_ENTITIES_PATH = getExportPath();
|
53 |
public static final String EXPORT_ENTITIES_PATH = getExportPath();
|
| 54 |
public static final String PRODUCT_PROPERTIES_SNIPPET = "ProductPropertiesSnippet.html";
|
54 |
public static final String PRODUCT_PROPERTIES_SNIPPET = "ProductPropertiesSnippet.html";
|
| 55 |
public static final String DOCUMENT_STORE = "/profitmandi/documents/";
|
55 |
public static final String DOCUMENT_STORE = "/profitmandi/documents/";
|
| 56 |
private Gson gson = new Gson();
|
56 |
private Gson gson = new Gson();
|
| 57 |
private static final Map<Integer, String> helpMap = new HashMap<>(6);
|
57 |
private static final Map<Integer, String> helpMap = new HashMap<>(6);
|
| 58 |
private static final Map<Integer, String> dthIdAliasMap = new HashMap<>(7);
|
58 |
private static final Map<Integer, String> dthIdAliasMap = new HashMap<>(7);
|
| 59 |
private static Map<Long, List<RechargePlan>> operatorPlanMap = new HashMap<>(20);
|
59 |
private static Map<Long, List<RechargePlan>> operatorPlanMap = new HashMap<>(20);
|
| 60 |
private static Map<Long, String> mobileProvidersMap;
|
60 |
private static Map<Long, String> mobileProvidersMap;
|
| 61 |
private static Map<Long, String> dthProvidersMap;
|
61 |
private static Map<Long, String> dthProvidersMap;
|
| 62 |
private static Map<Long, String> allProviders;
|
62 |
private static Map<Long, String> allProviders;
|
| 63 |
public static Map<RechargeOrderStatus, String> rechargeStatusMap = new HashMap<>();
|
63 |
public static Map<RechargeOrderStatus, String> rechargeStatusMap = new HashMap<>();
|
| 64 |
public static OrderStatusGroups ORDER_STATUS_GROUPS = new OrderStatusGroups();
|
64 |
public static OrderStatusGroups ORDER_STATUS_GROUPS = new OrderStatusGroups();
|
| 65 |
public static final String SYSTEM_PARTNER = "testpxps@gmail.com";
|
65 |
public static final String SYSTEM_PARTNER = "testpxps@gmail.com";
|
| 66 |
public static final int SYSTEM_PARTNER_ID = 175120474;
|
66 |
public static final int SYSTEM_PARTNER_ID = 175120474;
|
| 67 |
private static final RestClient rc = new RestClient();
|
67 |
private static final RestClient rc = new RestClient();
|
| 68 |
private static final String regex = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$";
|
68 |
private static final String regex = "^[a-zA-Z0-9_!#$%&'*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$";
|
| 69 |
public static final LocalTime MAX_TIME = LocalTime.of(23, 59, 59);
|
69 |
public static final LocalTime MAX_TIME = LocalTime.of(23, 59, 59);
|
| 70 |
// Compile regular expression to get the pattern
|
70 |
// Compile regular expression to get the pattern
|
| 71 |
private static final Pattern pattern = Pattern.compile(regex);
|
71 |
private static final Pattern pattern = Pattern.compile(regex);
|
| 72 |
|
72 |
|
| 73 |
public static boolean validateEmail(String email) {
|
73 |
public static boolean validateEmail(String email) {
|
| 74 |
if (email == null) {
|
74 |
if (email == null) {
|
| 75 |
return false;
|
75 |
return false;
|
| 76 |
}
|
76 |
}
|
| 77 |
Matcher matcher = pattern.matcher(email);
|
77 |
Matcher matcher = pattern.matcher(email);
|
| 78 |
return matcher.matches();
|
78 |
return matcher.matches();
|
| 79 |
}
|
79 |
}
|
| 80 |
|
80 |
|
| 81 |
@SuppressWarnings("serial")
|
81 |
@SuppressWarnings("serial")
|
| 82 |
public static final Map<String, String> MIME_TYPE = Collections.unmodifiableMap(new HashMap<String, String>() {
|
82 |
public static final Map<String, String> MIME_TYPE = Collections.unmodifiableMap(new HashMap<String, String>() {
|
| 83 |
{
|
83 |
{
|
| 84 |
put("image/png", "png");
|
84 |
put("image/png", "png");
|
| 85 |
put("image/jpeg", "jpeg");
|
85 |
put("image/jpeg", "jpeg");
|
| 86 |
put("image/pjpeg", "jpeg");
|
86 |
put("image/pjpeg", "jpeg");
|
| 87 |
put("application/pdf", "pdf");
|
87 |
put("application/pdf", "pdf");
|
| 88 |
put("application/msword", "doc");
|
88 |
put("application/msword", "doc");
|
| 89 |
put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx");
|
89 |
put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx");
|
| 90 |
put("application/vnd.ms-excel", "xls");
|
90 |
put("application/vnd.ms-excel", "xls");
|
| 91 |
put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
|
91 |
put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
|
| 92 |
}
|
92 |
}
|
| 93 |
});
|
93 |
});
|
| 94 |
|
94 |
|
| 95 |
private static String getExportPath() {
|
95 |
private static String getExportPath() {
|
| 96 |
String exportPath = "/var/lib/tomcat7/webapps/export/html/entities/";
|
96 |
String exportPath = "/var/lib/tomcat7/webapps/export/html/entities/";
|
| 97 |
/*
|
97 |
/*
|
| 98 |
* String exportPath = null;
|
98 |
* String exportPath = null;
|
| 99 |
*
|
99 |
*
|
| 100 |
* try { ConfigClient client = ConfigClient.getClient(); exportPath =
|
100 |
* try { ConfigClient client = ConfigClient.getClient(); exportPath =
|
| 101 |
* client.get("export_entities_path"); } catch (Exception ce) {
|
101 |
* client.get("export_entities_path"); } catch (Exception ce) {
|
| 102 |
* logger.error("Unable to read export path from the config client: ", ce);
|
102 |
* logger.error("Unable to read export path from the config client: ", ce);
|
| 103 |
* logger.warn("Setting the default export path"); exportPath =
|
103 |
* logger.warn("Setting the default export path"); exportPath =
|
| 104 |
* "/var/lib/tomcat7/webapps/export/html/entities/"; }
|
104 |
* "/var/lib/tomcat7/webapps/export/html/entities/"; }
|
| 105 |
*/
|
105 |
*/
|
| 106 |
return exportPath;
|
106 |
return exportPath;
|
| 107 |
}
|
107 |
}
|
| 108 |
|
108 |
|
| 109 |
public static LocalDateTime toLocalDateTime(long epochTimeInMillis) {
|
109 |
public static LocalDateTime toLocalDateTime(long epochTimeInMillis) {
|
| 110 |
return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochTimeInMillis), ZoneId.systemDefault());
|
110 |
return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochTimeInMillis), ZoneId.systemDefault());
|
| 111 |
}
|
111 |
}
|
| 112 |
|
112 |
|
| 113 |
public static String getRechargeDisplayStatus(RechargeOrderStatus status) {
|
113 |
public static String getRechargeDisplayStatus(RechargeOrderStatus status) {
|
| 114 |
if (status == null) {
|
114 |
if (status == null) {
|
| 115 |
status = RechargeOrderStatus.INIT;
|
115 |
status = RechargeOrderStatus.INIT;
|
| 116 |
}
|
116 |
}
|
| 117 |
String displayStatus = (String) rechargeStatusMap.get(status);
|
117 |
String displayStatus = (String) rechargeStatusMap.get(status);
|
| 118 |
if (displayStatus == null) {
|
118 |
if (displayStatus == null) {
|
| 119 |
return "";
|
119 |
return "";
|
| 120 |
}
|
120 |
}
|
| 121 |
return displayStatus;
|
121 |
return displayStatus;
|
| 122 |
}
|
122 |
}
|
| 123 |
|
123 |
|
| 124 |
public static boolean copyDocument(String documentPath) {
|
124 |
public static boolean copyDocument(String documentPath) {
|
| 125 |
File source = new File(documentPath);
|
125 |
File source = new File(documentPath);
|
| 126 |
File dest = new File(DOCUMENT_STORE + source.getName());
|
126 |
File dest = new File(DOCUMENT_STORE + source.getName());
|
| 127 |
try {
|
127 |
try {
|
| 128 |
FileUtils.copyFile(source, dest);
|
128 |
FileUtils.copyFile(source, dest);
|
| 129 |
} catch (IOException e) {
|
129 |
} catch (IOException e) {
|
| 130 |
e.printStackTrace();
|
130 |
e.printStackTrace();
|
| 131 |
return false;
|
131 |
return false;
|
| 132 |
}
|
132 |
}
|
| 133 |
return true;
|
133 |
return true;
|
| 134 |
}
|
134 |
}
|
| 135 |
|
135 |
|
| 136 |
public static Map<Long, String> getMobileProvidersMap() {
|
136 |
public static Map<Long, String> getMobileProvidersMap() {
|
| 137 |
return mobileProvidersMap;
|
137 |
return mobileProvidersMap;
|
| 138 |
}
|
138 |
}
|
| 139 |
|
139 |
|
| 140 |
public static Map<Long, String> getDthProvidersMap() {
|
140 |
public static Map<Long, String> getDthProvidersMap() {
|
| 141 |
return dthProvidersMap;
|
141 |
return dthProvidersMap;
|
| 142 |
}
|
142 |
}
|
| 143 |
|
143 |
|
| 144 |
public static Map<Long, String> getAllProviders() {
|
144 |
public static Map<Long, String> getAllProviders() {
|
| 145 |
return allProviders;
|
145 |
return allProviders;
|
| 146 |
}
|
146 |
}
|
| 147 |
|
147 |
|
| 148 |
public static String getProvider(long operatorId) {
|
148 |
public static String getProvider(long operatorId) {
|
| 149 |
return allProviders.get(operatorId);
|
149 |
return allProviders.get(operatorId);
|
| 150 |
}
|
150 |
}
|
| 151 |
|
151 |
|
| 152 |
public static void sendSms(String text, String mobileNumber) throws Exception {
|
152 |
public static void sendSms(String text, String mobileNumber) throws Exception {
|
| 153 |
Map<String, String> paramsMap = new HashMap<>();
|
153 |
Map<String, String> paramsMap = new HashMap<>();
|
| 154 |
paramsMap.put("username", "SmartDukaanT");
|
154 |
paramsMap.put("username", "SmartDukaanT");
|
| 155 |
paramsMap.put("password", "Smart@91");
|
155 |
paramsMap.put("password", "Smart@91");
|
| 156 |
paramsMap.put("senderID", "SMTDKN");
|
156 |
paramsMap.put("senderID", "SMTDKN");
|
| 157 |
paramsMap.put("message", text);
|
157 |
paramsMap.put("message", text);
|
| 158 |
paramsMap.put("mobile", mobileNumber);
|
158 |
paramsMap.put("mobile", mobileNumber);
|
| 159 |
paramsMap.put("messageType", "Text");
|
159 |
paramsMap.put("messageType", "Text");
|
| 160 |
// rc.getResponse(SMS_GATEWAY, paramsMap, null);
|
160 |
// rc.getResponse(SMS_GATEWAY, paramsMap, null);
|
| 161 |
}
|
161 |
}
|
| 162 |
|
162 |
|
| 163 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String emailTo, String[] cc, String subject,
|
163 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String emailTo, String[] cc, String subject,
|
| 164 |
String body, List<File> attachments) throws Exception {
|
164 |
String body, List<File> attachments) throws Exception {
|
| 165 |
MimeMessage message = mailSender.createMimeMessage();
|
165 |
MimeMessage message = mailSender.createMimeMessage();
|
| 166 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
166 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 167 |
helper.setSubject(subject);
|
167 |
helper.setSubject(subject);
|
| 168 |
helper.setText(body);
|
168 |
helper.setText(body);
|
| 169 |
if (cc != null) {
|
169 |
if (cc != null) {
|
| 170 |
helper.setCc(cc);
|
170 |
helper.setCc(cc);
|
| 171 |
}
|
171 |
}
|
| 172 |
helper.setTo(emailTo);
|
172 |
helper.setTo(emailTo);
|
| 173 |
// helper.setTo("amit.gupta@smartdukaan.com");
|
173 |
// helper.setTo("amit.gupta@smartdukaan.com");
|
| 174 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
174 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
| 175 |
helper.setFrom(senderAddress);
|
175 |
helper.setFrom(senderAddress);
|
| 176 |
if (attachments != null) {
|
176 |
if (attachments != null) {
|
| 177 |
for (File file : attachments) {
|
177 |
for (File file : attachments) {
|
| 178 |
helper.addAttachment(file.getName(), file);
|
178 |
helper.addAttachment(file.getName(), file);
|
| 179 |
}
|
179 |
}
|
| 180 |
}
|
180 |
}
|
| 181 |
mailSender.send(message);
|
181 |
mailSender.send(message);
|
| 182 |
}
|
182 |
}
|
| 183 |
|
183 |
|
| 184 |
public static class Attachment {
|
184 |
public static class Attachment {
|
| 185 |
public Attachment(String fileName, InputStreamSource inputStreamSource) {
|
185 |
public Attachment(String fileName, InputStreamSource inputStreamSource) {
|
| 186 |
this.fileName = fileName;
|
186 |
this.fileName = fileName;
|
| 187 |
this.inputStreamSource = inputStreamSource;
|
187 |
this.inputStreamSource = inputStreamSource;
|
| 188 |
}
|
188 |
}
|
| 189 |
|
189 |
|
| 190 |
private String fileName;
|
190 |
private String fileName;
|
| 191 |
private InputStreamSource inputStreamSource;
|
191 |
private InputStreamSource inputStreamSource;
|
| 192 |
|
192 |
|
| 193 |
public String getFileName() {
|
193 |
public String getFileName() {
|
| 194 |
return fileName;
|
194 |
return fileName;
|
| 195 |
}
|
195 |
}
|
| 196 |
|
196 |
|
| 197 |
public void setFileName(String fileName) {
|
197 |
public void setFileName(String fileName) {
|
| 198 |
this.fileName = fileName;
|
198 |
this.fileName = fileName;
|
| 199 |
}
|
199 |
}
|
| 200 |
|
200 |
|
| 201 |
public InputStreamSource getInputStreamSource() {
|
201 |
public InputStreamSource getInputStreamSource() {
|
| 202 |
return inputStreamSource;
|
202 |
return inputStreamSource;
|
| 203 |
}
|
203 |
}
|
| 204 |
|
204 |
|
| 205 |
public void setInputStreamSource(InputStreamSource inputStreamSource) {
|
205 |
public void setInputStreamSource(InputStreamSource inputStreamSource) {
|
| 206 |
this.inputStreamSource = inputStreamSource;
|
206 |
this.inputStreamSource = inputStreamSource;
|
| 207 |
}
|
207 |
}
|
| 208 |
|
208 |
|
| 209 |
@Override
|
209 |
@Override
|
| 210 |
public String toString() {
|
210 |
public String toString() {
|
| 211 |
return "Attachment [fileName=" + fileName + ", inputStreamSource=" + inputStreamSource + "]";
|
211 |
return "Attachment [fileName=" + fileName + ", inputStreamSource=" + inputStreamSource + "]";
|
| 212 |
}
|
212 |
}
|
| 213 |
}
|
213 |
}
|
| 214 |
|
214 |
|
| 215 |
public static void sendMailWithAttachment(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
|
215 |
public static void sendMailWithAttachment(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
|
| 216 |
String body, String fileName, InputStreamSource inputStreamSource) throws Exception {
|
216 |
String body, String fileName, InputStreamSource inputStreamSource) throws Exception {
|
| 217 |
MimeMessage message = mailSender.createMimeMessage();
|
217 |
MimeMessage message = mailSender.createMimeMessage();
|
| 218 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
218 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 219 |
helper.setSubject(subject);
|
219 |
helper.setSubject(subject);
|
| 220 |
helper.setText(body);
|
220 |
helper.setText(body);
|
| 221 |
if (cc != null) {
|
221 |
if (cc != null) {
|
| 222 |
helper.setCc(cc);
|
222 |
helper.setCc(cc);
|
| 223 |
}
|
223 |
}
|
| 224 |
helper.setTo(emailTo);
|
224 |
helper.setTo(emailTo);
|
| 225 |
helper.addAttachment(fileName, inputStreamSource);
|
225 |
helper.addAttachment(fileName, inputStreamSource);
|
| 226 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
226 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
| 227 |
helper.setFrom(senderAddress);
|
227 |
helper.setFrom(senderAddress);
|
| 228 |
mailSender.send(message);
|
228 |
mailSender.send(message);
|
| 229 |
}
|
229 |
}
|
| 230 |
|
230 |
|
| 231 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc, String[] bcc,
|
231 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc, String[] bcc,
|
| 232 |
String subject, String body, Attachment... attachments) throws Exception {
|
232 |
String subject, String body, Attachment... attachments) throws Exception {
|
| 233 |
MimeMessage message = mailSender.createMimeMessage();
|
233 |
sendMailWithAttachments(mailSender, emailTo, cc, bcc,
|
| 234 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
234 |
subject, body, false, attachments);
|
| 235 |
helper.setSubject(subject);
|
235 |
}
|
| 236 |
helper.setText(body);
|
236 |
|
| 237 |
if (cc != null) {
|
237 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc, String[] bcc,
|
| 238 |
helper.setCc(cc);
|
238 |
String subject, String body, boolean html, Attachment... attachments) throws Exception {
|
| 239 |
}
|
239 |
MimeMessage message = mailSender.createMimeMessage();
|
| 240 |
if (bcc != null) {
|
240 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 241 |
helper.setBcc(bcc);
|
241 |
helper.setSubject(subject);
|
| 242 |
}
|
242 |
helper.setText(body, html);
|
| 243 |
helper.setTo(emailTo);
|
243 |
if (cc != null) {
|
| 244 |
for (Attachment attachment : attachments) {
|
244 |
helper.setCc(cc);
|
| 245 |
helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
|
245 |
}
|
| 246 |
}
|
246 |
if (bcc != null) {
|
| 247 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
247 |
helper.setBcc(bcc);
|
| 248 |
helper.setFrom(senderAddress);
|
248 |
}
|
| 249 |
mailSender.send(message);
|
249 |
helper.setTo(emailTo);
|
| 250 |
}
|
250 |
for (Attachment attachment : attachments) {
|
| 251 |
|
251 |
helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
|
| 252 |
public static void sendHtmlMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc,
|
252 |
}
|
| 253 |
String subject, String body, Attachment... attachments) throws Exception {
|
253 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
| 254 |
MimeMessage message = mailSender.createMimeMessage();
|
254 |
helper.setFrom(senderAddress);
|
| 255 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
255 |
mailSender.send(message);
|
| 256 |
helper.setSubject(subject);
|
256 |
}
|
| 257 |
helper.setText(body, true);
|
257 |
|
| 258 |
// helper.setText(body, true);
|
258 |
public static void sendHtmlMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc,
|
| 259 |
if (cc != null) {
|
259 |
String subject, String body, Attachment... attachments) throws Exception {
|
| 260 |
helper.setCc(cc);
|
260 |
MimeMessage message = mailSender.createMimeMessage();
|
| 261 |
}
|
261 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 262 |
helper.setTo(emailTo);
|
262 |
helper.setSubject(subject);
|
| 263 |
for (Attachment attachment : attachments) {
|
263 |
helper.setText(body, true);
|
| 264 |
if (attachment == null)
|
264 |
// helper.setText(body, true);
|
| 265 |
break;
|
265 |
if (cc != null) {
|
| 266 |
helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
|
266 |
helper.setCc(cc);
|
| 267 |
}
|
267 |
}
|
| 268 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
268 |
helper.setTo(emailTo);
|
| 269 |
helper.setFrom(senderAddress);
|
269 |
for (Attachment attachment : attachments) {
|
| 270 |
mailSender.send(message);
|
270 |
if (attachment == null)
|
| 271 |
}
|
271 |
break;
|
| 272 |
|
272 |
helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
|
| 273 |
public static String[] getOrderStatus(RechargeOrderStatus status) {
|
273 |
}
|
| 274 |
if (status == null) {
|
274 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
| 275 |
status = RechargeOrderStatus.INIT;
|
275 |
helper.setFrom(senderAddress);
|
| 276 |
}
|
276 |
mailSender.send(message);
|
| 277 |
if (status.equals(RechargeOrderStatus.PAYMENT_FAILED) || status.equals(RechargeOrderStatus.PAYMENT_PENDING)) {
|
277 |
}
|
| 278 |
return new String[] { "false", "PAYMENT FAILED", "Payment failed at the payment gateway." };
|
278 |
|
| 279 |
} else if (status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)
|
279 |
public static String[] getOrderStatus(RechargeOrderStatus status) {
|
| 280 |
|| status.equals(RechargeOrderStatus.RECHARGE_UNKNOWN)) {
|
280 |
if (status == null) {
|
| 281 |
if (status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)) {
|
281 |
status = RechargeOrderStatus.INIT;
|
| 282 |
return new String[] { "false", "PAYMENT SUCCESSFUL",
|
282 |
}
|
| 283 |
"Your Payment was successful but due to some internal error with the operator's system we are not sure if the recharge was successful."
|
283 |
if (status.equals(RechargeOrderStatus.PAYMENT_FAILED) || status.equals(RechargeOrderStatus.PAYMENT_PENDING)) {
|
| 284 |
+ " We have put your recharge under process."
|
284 |
return new String[]{"false", "PAYMENT FAILED", "Payment failed at the payment gateway."};
|
| 285 |
+ " As soon as we get a confirmation on this transaction, we will notify you." };
|
285 |
} else if (status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)
|
| 286 |
} else {
|
286 |
|| status.equals(RechargeOrderStatus.RECHARGE_UNKNOWN)) {
|
| 287 |
return new String[] { "false", "RECHARGE IN PROCESS",
|
287 |
if (status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)) {
|
| 288 |
"Your Payment is successful.We have put your recharge under process."
|
288 |
return new String[]{"false", "PAYMENT SUCCESSFUL",
|
| 289 |
+ " Please wait while we check with the operator." };
|
289 |
"Your Payment was successful but due to some internal error with the operator's system we are not sure if the recharge was successful."
|
| 290 |
}
|
290 |
+ " We have put your recharge under process."
|
| 291 |
} else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED)
|
291 |
+ " As soon as we get a confirmation on this transaction, we will notify you."};
|
| 292 |
|| status.equals(RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)) {
|
292 |
} else {
|
| 293 |
return new String[] { "false", "RECHARGE FAILED",
|
293 |
return new String[]{"false", "RECHARGE IN PROCESS",
|
| 294 |
"Your Payment was successful but unfortunately the recharge failed.Don't worry your payment is safe with us."
|
294 |
"Your Payment is successful.We have put your recharge under process."
|
| 295 |
+ " The entire Amount has been refunded to your wallet." };
|
295 |
+ " Please wait while we check with the operator."};
|
| 296 |
} else if (status.equals(RechargeOrderStatus.RECHARGE_SUCCESSFUL)) {
|
296 |
}
|
| 297 |
return new String[] { "false", "SUCCESS", "Congratulations! Your device is successfully recharged." };
|
297 |
} else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED)
|
| 298 |
} else if (status.equals(RechargeOrderStatus.PARTIALLY_REFUNDED)
|
298 |
|| status.equals(RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)) {
|
| 299 |
|| status.equals(RechargeOrderStatus.REFUNDED)) {
|
299 |
return new String[]{"false", "RECHARGE FAILED",
|
| 300 |
return new String[] { "false", "PAYMENT REFUNDED",
|
300 |
"Your Payment was successful but unfortunately the recharge failed.Don't worry your payment is safe with us."
|
| 301 |
"The payment associated with this recharge order has been refunded." };
|
301 |
+ " The entire Amount has been refunded to your wallet."};
|
| 302 |
} else {
|
302 |
} else if (status.equals(RechargeOrderStatus.RECHARGE_SUCCESSFUL)) {
|
| 303 |
return new String[] { "true", "ERROR", "INVALID INPUT" };
|
303 |
return new String[]{"false", "SUCCESS", "Congratulations! Your device is successfully recharged."};
|
| 304 |
}
|
304 |
} else if (status.equals(RechargeOrderStatus.PARTIALLY_REFUNDED)
|
| 305 |
}
|
305 |
|| status.equals(RechargeOrderStatus.REFUNDED)) {
|
| 306 |
|
306 |
return new String[]{"false", "PAYMENT REFUNDED",
|
| 307 |
public static String getIconUrl(int entityId, String host, int port, String webapp) {
|
307 |
"The payment associated with this recharge order has been refunded."};
|
| 308 |
return "";
|
308 |
} else {
|
| 309 |
}
|
309 |
return new String[]{"true", "ERROR", "INVALID INPUT"};
|
| 310 |
|
310 |
}
|
| 311 |
|
311 |
}
|
| 312 |
private static WarehouseService.Client getWarehouseClient() throws Exception {
|
312 |
|
| 313 |
try {
|
313 |
public static String getIconUrl(int entityId, String host, int port, String webapp) {
|
| 314 |
WarehouseClient client = new WarehouseClient();
|
314 |
return "";
|
| 315 |
WarehouseService.Client warehouseClient = client.getClient();
|
315 |
}
|
| 316 |
return warehouseClient;
|
316 |
|
| 317 |
} catch (Exception e) {
|
317 |
|
| 318 |
throw e;
|
318 |
private static WarehouseService.Client getWarehouseClient() throws Exception {
|
| 319 |
}
|
319 |
try {
|
| 320 |
}
|
320 |
WarehouseClient client = new WarehouseClient();
|
| 321 |
|
321 |
WarehouseService.Client warehouseClient = client.getClient();
|
| 322 |
public static Map<String, Warehouse> getWarehouseByImeis(List<String> imeis) throws Exception {
|
322 |
return warehouseClient;
|
| 323 |
List<InventoryItem> inventoryItems = getWarehouseClient().getInventoryItemsBySerailNumbers(imeis);
|
323 |
} catch (Exception e) {
|
| 324 |
Map<String, InventoryItem> imeiInventoryItemMap = new HashMap<>();
|
324 |
throw e;
|
| 325 |
for (InventoryItem inventoryItem : inventoryItems) {
|
325 |
}
|
| 326 |
imeiInventoryItemMap.put(inventoryItem.getSerialNumber(), inventoryItem);
|
326 |
}
|
| 327 |
}
|
327 |
|
| 328 |
Map<Integer, Warehouse> warehouseMap = new HashMap<>();
|
328 |
public static Map<String, Warehouse> getWarehouseByImeis(List<String> imeis) throws Exception {
|
| 329 |
Map<String, Warehouse> serialNumberWarehouseMap = new HashMap<>();
|
329 |
List<InventoryItem> inventoryItems = getWarehouseClient().getInventoryItemsBySerailNumbers(imeis);
|
| 330 |
InventoryClient client = new InventoryClient();
|
330 |
Map<String, InventoryItem> imeiInventoryItemMap = new HashMap<>();
|
| 331 |
InventoryService.Client inventoryClient = client.getClient();
|
331 |
for (InventoryItem inventoryItem : inventoryItems) {
|
| 332 |
logger.info("[imeiInventoryItemMap] {}", imeiInventoryItemMap);
|
332 |
imeiInventoryItemMap.put(inventoryItem.getSerialNumber(), inventoryItem);
|
| 333 |
for (InventoryItem inventory : new HashSet<>(imeiInventoryItemMap.values())) {
|
333 |
}
|
| 334 |
Warehouse phWarehouse = null;
|
334 |
Map<Integer, Warehouse> warehouseMap = new HashMap<>();
|
| 335 |
if (warehouseMap.containsKey(inventory.getPhysicalWarehouseId())) {
|
335 |
Map<String, Warehouse> serialNumberWarehouseMap = new HashMap<>();
|
| 336 |
phWarehouse = warehouseMap.get((int) inventory.getPhysicalWarehouseId());
|
336 |
InventoryClient client = new InventoryClient();
|
| 337 |
} else {
|
337 |
InventoryService.Client inventoryClient = client.getClient();
|
| 338 |
phWarehouse = inventoryClient.getWarehouse(inventory.getPhysicalWarehouseId());
|
338 |
logger.info("[imeiInventoryItemMap] {}", imeiInventoryItemMap);
|
| 339 |
warehouseMap.put((int) inventory.getPhysicalWarehouseId(), phWarehouse);
|
339 |
for (InventoryItem inventory : new HashSet<>(imeiInventoryItemMap.values())) {
|
| 340 |
}
|
340 |
Warehouse phWarehouse = null;
|
| 341 |
serialNumberWarehouseMap.put(inventory.getSerialNumber(), phWarehouse);
|
341 |
if (warehouseMap.containsKey(inventory.getPhysicalWarehouseId())) {
|
| 342 |
|
342 |
phWarehouse = warehouseMap.get((int) inventory.getPhysicalWarehouseId());
|
| 343 |
}
|
343 |
} else {
|
| 344 |
return serialNumberWarehouseMap;
|
344 |
phWarehouse = inventoryClient.getWarehouse(inventory.getPhysicalWarehouseId());
|
| 345 |
}
|
345 |
warehouseMap.put((int) inventory.getPhysicalWarehouseId(), phWarehouse);
|
| 346 |
|
346 |
}
|
| 347 |
public static Map<Integer, Warehouse> getWarehousesByIds(Set<Integer> warehouseIds) throws Exception {
|
347 |
serialNumberWarehouseMap.put(inventory.getSerialNumber(), phWarehouse);
|
| 348 |
InventoryClient client = new InventoryClient();
|
348 |
|
| 349 |
InventoryService.Client inventoryClient = client.getClient();
|
349 |
}
|
| 350 |
Map<Integer, Warehouse> warehouseMap = new HashMap<>();
|
350 |
return serialNumberWarehouseMap;
|
| 351 |
for (Integer warehouseId : warehouseIds) {
|
351 |
}
|
| 352 |
warehouseMap.put(warehouseId, inventoryClient.getWarehouse(warehouseId));
|
352 |
|
| 353 |
}
|
353 |
public static Map<Integer, Warehouse> getWarehousesByIds(Set<Integer> warehouseIds) throws Exception {
|
| 354 |
return warehouseMap;
|
354 |
InventoryClient client = new InventoryClient();
|
| 355 |
}
|
355 |
InventoryService.Client inventoryClient = client.getClient();
|
| 356 |
|
356 |
Map<Integer, Warehouse> warehouseMap = new HashMap<>();
|
| 357 |
public static String getStateCode(String stateName) throws Exception {
|
357 |
for (Integer warehouseId : warehouseIds) {
|
| 358 |
return getStateInfo(stateName).getStateCode();
|
358 |
warehouseMap.put(warehouseId, inventoryClient.getWarehouse(warehouseId));
|
| 359 |
}
|
359 |
}
|
| 360 |
|
360 |
return warehouseMap;
|
| 361 |
public static long getStateId(String stateName) throws ProfitMandiBusinessException {
|
361 |
}
|
| 362 |
try {
|
362 |
|
| 363 |
return getStateInfo(stateName).getId();
|
363 |
public static String getStateCode(String stateName) throws Exception {
|
| 364 |
} catch (Exception e) {
|
364 |
return getStateInfo(stateName).getStateCode();
|
| 365 |
e.printStackTrace();
|
365 |
}
|
| 366 |
throw new ProfitMandiBusinessException("State Name", stateName, "Could not fetch state");
|
366 |
|
| 367 |
}
|
367 |
public static long getStateId(String stateName) throws ProfitMandiBusinessException {
|
| 368 |
}
|
368 |
try {
|
| 369 |
|
369 |
return getStateInfo(stateName).getId();
|
| 370 |
public static StateInfo getStateByStateId(long stateId) throws Exception {
|
370 |
} catch (Exception e) {
|
| 371 |
InventoryClient client = new InventoryClient();
|
371 |
e.printStackTrace();
|
| 372 |
InventoryService.Client inventoryClient = client.getClient();
|
372 |
throw new ProfitMandiBusinessException("State Name", stateName, "Could not fetch state");
|
| 373 |
Map<Long, StateInfo> map = inventoryClient.getStateMaster();
|
373 |
}
|
| 374 |
return map.get(stateId);
|
374 |
}
|
| 375 |
}
|
375 |
|
| 376 |
|
376 |
public static StateInfo getStateByStateId(long stateId) throws Exception {
|
| 377 |
public static StateInfo getStateInfo(String stateName) throws Exception {
|
377 |
InventoryClient client = new InventoryClient();
|
| 378 |
try {
|
378 |
InventoryService.Client inventoryClient = client.getClient();
|
| 379 |
InventoryClient client = new InventoryClient();
|
379 |
Map<Long, StateInfo> map = inventoryClient.getStateMaster();
|
| 380 |
InventoryService.Client inventoryClient = client.getClient();
|
380 |
return map.get(stateId);
|
| 381 |
Map<Long, StateInfo> map = inventoryClient.getStateMaster();
|
381 |
}
|
| 382 |
List<StateInfo> stateInfos = new ArrayList<>(map.values());
|
382 |
|
| 383 |
logger.info("State Name: {}", stateName);
|
383 |
public static StateInfo getStateInfo(String stateName) throws Exception {
|
| 384 |
for (StateInfo stateInfo : stateInfos) {
|
384 |
try {
|
| 385 |
logger.info("State Name from service: {}", stateInfo.getStateName());
|
385 |
InventoryClient client = new InventoryClient();
|
| 386 |
if (stateName.toUpperCase().equals(stateInfo.getStateName().toUpperCase())) {
|
386 |
InventoryService.Client inventoryClient = client.getClient();
|
| 387 |
return stateInfo;
|
387 |
Map<Long, StateInfo> map = inventoryClient.getStateMaster();
|
| 388 |
}
|
388 |
List<StateInfo> stateInfos = new ArrayList<>(map.values());
|
| 389 |
}
|
389 |
logger.info("State Name: {}", stateName);
|
| 390 |
throw new Exception("Not found");
|
390 |
for (StateInfo stateInfo : stateInfos) {
|
| 391 |
} catch (Exception e) {
|
391 |
logger.info("State Name from service: {}", stateInfo.getStateName());
|
| 392 |
e.printStackTrace();
|
392 |
if (stateName.toUpperCase().equals(stateInfo.getStateName().toUpperCase())) {
|
| 393 |
throw e;
|
393 |
return stateInfo;
|
| 394 |
}
|
394 |
}
|
| 395 |
}
|
395 |
}
|
| 396 |
|
396 |
throw new Exception("Not found");
|
| 397 |
public static void main(String[] args) throws Exception {
|
397 |
} catch (Exception e) {
|
| 398 |
Utils.sendSms("Hello", "9990381569");
|
398 |
e.printStackTrace();
|
| 399 |
}
|
399 |
throw e;
|
| 400 |
|
400 |
}
|
| 401 |
public static void sendEmbeddedHtmlMail(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
|
401 |
}
|
| 402 |
String body, Map<? extends Serializable, File> map) throws Exception {
|
402 |
|
| 403 |
MimeMessage message = mailSender.createMimeMessage();
|
403 |
public static void main(String[] args) throws Exception {
|
| 404 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
404 |
Utils.sendSms("Hello", "9990381569");
|
| 405 |
helper.setSubject(subject);
|
405 |
}
|
| 406 |
Multipart mp = new MimeMultipart();
|
406 |
|
| 407 |
|
407 |
public static void sendEmbeddedHtmlMail(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
|
| 408 |
MimeBodyPart messageBodyPart = new MimeBodyPart();
|
408 |
String body, Map<? extends Serializable, File> map) throws Exception {
|
| 409 |
messageBodyPart.setContent(body, "text/html");
|
409 |
MimeMessage message = mailSender.createMimeMessage();
|
| 410 |
mp.addBodyPart(messageBodyPart);
|
410 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 411 |
|
411 |
helper.setSubject(subject);
|
| 412 |
// helper.setText(body, true);
|
412 |
Multipart mp = new MimeMultipart();
|
| 413 |
if (cc != null) {
|
413 |
|
| 414 |
helper.setCc(cc);
|
414 |
MimeBodyPart messageBodyPart = new MimeBodyPart();
|
| 415 |
}
|
415 |
messageBodyPart.setContent(body, "text/html");
|
| 416 |
helper.setTo(emailTo);
|
416 |
mp.addBodyPart(messageBodyPart);
|
| 417 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
417 |
|
| 418 |
helper.setFrom(senderAddress);
|
418 |
// helper.setText(body, true);
|
| 419 |
for (Map.Entry<? extends Serializable, File> entry : map.entrySet()) {
|
419 |
if (cc != null) {
|
| 420 |
entry.getKey();
|
420 |
helper.setCc(cc);
|
| 421 |
entry.getValue();
|
421 |
}
|
| 422 |
MimeBodyPart imagePart = new MimeBodyPart();
|
422 |
helper.setTo(emailTo);
|
| 423 |
imagePart.setHeader("Content-ID", entry.getKey() + "");
|
423 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
| 424 |
imagePart.setDisposition(MimeBodyPart.INLINE);
|
424 |
helper.setFrom(senderAddress);
|
| 425 |
imagePart.attachFile(entry.getValue());
|
425 |
for (Map.Entry<? extends Serializable, File> entry : map.entrySet()) {
|
| 426 |
mp.addBodyPart(imagePart);
|
426 |
entry.getKey();
|
| 427 |
|
427 |
entry.getValue();
|
| 428 |
}
|
428 |
MimeBodyPart imagePart = new MimeBodyPart();
|
| 429 |
message.setContent(mp);
|
429 |
imagePart.setHeader("Content-ID", entry.getKey() + "");
|
| 430 |
mailSender.send(message);
|
430 |
imagePart.setDisposition(MimeBodyPart.INLINE);
|
| 431 |
|
431 |
imagePart.attachFile(entry.getValue());
|
| 432 |
}
|
432 |
mp.addBodyPart(imagePart);
|
| 433 |
|
433 |
|
| 434 |
public String html(String string) {
|
434 |
}
|
| 435 |
return org.apache.commons.lang.StringEscapeUtils.escapeHtml(String.valueOf(string));
|
435 |
message.setContent(mp);
|
| 436 |
}
|
436 |
mailSender.send(message);
|
| 437 |
|
437 |
|
| 438 |
public String htmlJson(Object object) {
|
438 |
}
|
| 439 |
return StringEscapeUtils.escapeHtml4(gson.toJson(object));
|
439 |
|
| 440 |
}
|
440 |
public String html(String string) {
|
| 441 |
|
441 |
return org.apache.commons.lang.StringEscapeUtils.escapeHtml(String.valueOf(string));
|
| 442 |
public static String getHyphenatedString(String s) {
|
442 |
}
|
| 443 |
s = s.trim().replaceAll("\\s+", " ");
|
443 |
|
| 444 |
s = s.replaceAll("\\s", "-");
|
444 |
public String htmlJson(Object object) {
|
| 445 |
return s.toLowerCase();
|
445 |
return StringEscapeUtils.escapeHtml4(gson.toJson(object));
|
| 446 |
}
|
446 |
}
|
| 447 |
|
447 |
|
| 448 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
|
448 |
public static String getHyphenatedString(String s) {
|
| 449 |
String body, Attachment... attachments) throws Exception {
|
449 |
s = s.trim().replaceAll("\\s+", " ");
|
| 450 |
MimeMessage message = mailSender.createMimeMessage();
|
450 |
s = s.replaceAll("\\s", "-");
|
| 451 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
451 |
return s.toLowerCase();
|
| 452 |
helper.setSubject(subject);
|
452 |
}
|
| 453 |
helper.setText(body, true);
|
453 |
|
| 454 |
if (cc != null) {
|
454 |
public static void sendMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
|
| 455 |
helper.setCc(cc);
|
455 |
String body, Attachment... attachments) throws Exception {
|
| 456 |
}
|
456 |
MimeMessage message = mailSender.createMimeMessage();
|
| 457 |
helper.setTo(emailTo);
|
457 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 458 |
for (Attachment attachment : attachments) {
|
458 |
helper.setSubject(subject);
|
| 459 |
helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
|
459 |
helper.setText(body, true);
|
| 460 |
}
|
460 |
if (cc != null) {
|
| 461 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
461 |
helper.setCc(cc);
|
| 462 |
helper.setFrom(senderAddress);
|
462 |
}
|
| 463 |
mailSender.send(message);
|
463 |
helper.setTo(emailTo);
|
| 464 |
}
|
464 |
for (Attachment attachment : attachments) {
|
| 465 |
|
465 |
helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
|
| 466 |
public static int compareFloat(float f1, float f2) {
|
466 |
}
|
| 467 |
if (Math.abs(f1 - f2) < DOUBLE_EPSILON) {
|
467 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
|
| 468 |
return 0;
|
468 |
helper.setFrom(senderAddress);
|
| 469 |
}
|
469 |
mailSender.send(message);
|
| 470 |
|
470 |
}
|
| 471 |
return Float.compare(f1, f2);
|
471 |
|
| 472 |
}
|
472 |
public static int compareFloat(float f1, float f2) {
|
| 473 |
|
473 |
if (Math.abs(f1 - f2) < DOUBLE_EPSILON) {
|
| 474 |
public static int compareDouble(double d1, double d2) {
|
474 |
return 0;
|
| 475 |
if (Math.abs(d1 - d2) < DOUBLE_EPSILON) {
|
475 |
}
|
| 476 |
return 0;
|
476 |
|
| 477 |
}
|
477 |
return Float.compare(f1, f2);
|
| 478 |
return Double.compare(d1, d2);
|
478 |
}
|
| 479 |
}
|
479 |
|
| 480 |
|
480 |
public static int compareDouble(double d1, double d2) {
|
| 481 |
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
481 |
if (Math.abs(d1 - d2) < DOUBLE_EPSILON) {
|
| 482 |
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
482 |
return 0;
|
| 483 |
return t -> seen.add(keyExtractor.apply(t));
|
483 |
}
|
| 484 |
}
|
484 |
return Double.compare(d1, d2);
|
| 485 |
|
485 |
}
|
| 486 |
public static <T> Predicate<T> smallestByKey(Function<? super T, ?> keyExtractor) {
|
486 |
|
| 487 |
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
487 |
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
| 488 |
return t -> seen.add(keyExtractor.apply(t));
|
488 |
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
| 489 |
}
|
489 |
return t -> seen.add(keyExtractor.apply(t));
|
| 490 |
|
490 |
}
|
| 491 |
public static LocalDate convertToLocalDate(Date dateToConvert) {
|
491 |
|
| 492 |
return Instant.ofEpochMilli(dateToConvert.getTime())
|
492 |
public static <T> Predicate<T> smallestByKey(Function<? super T, ?> keyExtractor) {
|
| 493 |
.atZone(ZoneId.systemDefault())
|
493 |
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
| 494 |
.toLocalDate();
|
494 |
return t -> seen.add(keyExtractor.apply(t));
|
| 495 |
}
|
495 |
}
|
| 496 |
public static LocalDateTime convertToLocalDateTime(Date dateToConvert) {
|
496 |
|
| 497 |
return Instant.ofEpochMilli(dateToConvert.getTime())
|
497 |
public static LocalDate convertToLocalDate(Date dateToConvert) {
|
| 498 |
.atZone(ZoneId.systemDefault())
|
498 |
return Instant.ofEpochMilli(dateToConvert.getTime())
|
| 499 |
.toLocalDateTime();
|
499 |
.atZone(ZoneId.systemDefault())
|
| 500 |
}
|
500 |
.toLocalDate();
|
| - |
|
501 |
}
|
| - |
|
502 |
|
| - |
|
503 |
public static LocalDateTime convertToLocalDateTime(Date dateToConvert) {
|
| - |
|
504 |
return Instant.ofEpochMilli(dateToConvert.getTime())
|
| - |
|
505 |
.atZone(ZoneId.systemDefault())
|
| - |
|
506 |
.toLocalDateTime();
|
| - |
|
507 |
}
|
| 501 |
|
508 |
|
| 502 |
}
|
509 |
}
|
| 503 |
|
510 |
|