1 package compbio.cassandra;
3 import java.text.ParseException;
4 import java.text.SimpleDateFormat;
7 public class DateFormatter {
8 private final static SimpleDateFormat formatYYMMDD = new SimpleDateFormat("yyyy/MM/dd");
9 private final static SimpleDateFormat formatDDMMYY = new SimpleDateFormat("dd/MM/yyyy");
12 * convert String date into long date (miliseconds since the epoch start)
14 public static long DateParsing(String datInput, SimpleDateFormat formatter) {
15 if (datInput == null) {
21 dateWorkSt = formatter.parse(datInput).getTime();
22 } catch (ParseException e) {
29 * date validator true - if valid date, false - if invalid
31 public static boolean isThisDateValid(String dateToValidate, SimpleDateFormat sdf) {
32 if (dateToValidate == null || dateToValidate.equals("")) {
36 // if not valid, this will throw ParseException
37 sdf.setLenient(false);
38 Date date = sdf.parse(dateToValidate);
39 } catch (ParseException e) {
47 * convert date from long to String
49 public static String DateLongToString(long indate, SimpleDateFormat formatter) {
50 String dateString = formatter.format(new Date(indate));
54 public static SimpleDateFormat getFormatYYMMDD() {
58 public static SimpleDateFormat getFormatDDMMYY() {