Skip to content

Commit 632c505

Browse files
committed
1. Added method to get current date time in given format.
2. Updated library version.
1 parent 48569cd commit 632c505

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
defaultConfig {
1111
minSdkVersion 19
1212
targetSdkVersion 28
13-
versionCode 33 // this indicates the number of releases of library
14-
versionName "1.3.5" // this indicates the current version of library
13+
versionCode 34 // this indicates the number of releases of library
14+
versionName "1.3.6" // this indicates the current version of library
1515
}
1616

1717
buildTypes {

app/src/main/java/com/amit/utilities/DateTimeUtils.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,35 @@
1313
* <p>
1414
* this class will help in formatting date and time
1515
**/
16-
@SuppressWarnings("unused, deprecation")
16+
@SuppressWarnings({"unused, deprecation", "WeakerAccess"})
1717
public class DateTimeUtils
1818
{
1919
private static final String TAG = DateTimeUtils.class.getSimpleName();
2020

21+
/**
22+
* 2018 November 03 - Saturday - 12:00 PM
23+
* get current date time method
24+
*
25+
* this method will current date time in string type
26+
*
27+
* @param inDateTimeFormat - Pass the date or date time format you
28+
* want to get date or date time in format
29+
* Ex: dd-MM-yyyy or dd-MM-yyyy hh:mm
30+
*
31+
* @return - date or date time returned
32+
**/
33+
private static String getCurrentDateTime(String inDateTimeFormat)
34+
{
35+
if (inDateTimeFormat != null && inDateTimeFormat.length() != 0)
36+
{
37+
String dateTime = java.text.DateFormat.getDateTimeInstance().format(new Date());
38+
return DateTimeUtils.formatDateTime(dateTime, inDateTimeFormat);
39+
}
40+
41+
Log.e(TAG, "getCurrentDateTime: given date format is not valid");
42+
return "";
43+
}
44+
2145
/**
2246
* format date time method
2347
* <p>

0 commit comments

Comments
 (0)