summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java
diff options
context:
space:
mode:
authorlalottacontinua <loddatio@posteo.de>2018-06-27 22:44:33 +0200
committerlalottacontinua <loddatio@posteo.de>2018-06-27 22:44:33 +0200
commitd63dd4b36701f2f993e671f8cc3c5424b787e43a (patch)
tree486a8c3a1a688e76c7da7f5d9f8dfddbcc0b58aa /app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java
parent277f0f12ca505797daec42a5211885ac07b909f9 (diff)
parent8c9879145e588e985e5305ee2f88dfc1b6bf1d10 (diff)
Merge branch 'master' into add_provider
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java b/app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java
new file mode 100644
index 00000000..523c8c4c
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/utils/DateHelper.java
@@ -0,0 +1,29 @@
+package se.leap.bitmaskclient.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Contains helper methods related to date manipulation.
+ *
+ * @author Janak
+ */
+public class DateHelper {
+ private static final String DATE_PATTERN = "dd/MM/yyyy";
+ private static final int ONE_DAY = 86400000; //1000*60*60*24
+
+ public static long getDateDiffToCurrentDateInDays(String startDate) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN, Locale.US);
+ Date lastDate = sdf.parse(startDate);
+ Date currentDate = new Date();
+ return (currentDate.getTime() - lastDate.getTime()) / ONE_DAY;
+ }
+
+ public static String getCurrentDateString() {
+ SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN, Locale.US);
+ Date lastDate = new Date();
+ return sdf.format(lastDate);
+ }
+}