mirror of
https://github.com/hmalik144/Driver.git
synced 2025-12-10 02:45:20 +00:00
- code clean up
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package h_mal.appttude.com.driver.data
|
||||
|
||||
const val DRIVER = "driver"
|
||||
const val ADMIN = "super_user"
|
||||
const val ADMIN = "admin"
|
||||
@@ -1,16 +0,0 @@
|
||||
package h_mal.appttude.com.driver.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
object ActivityIntentBuilder {
|
||||
|
||||
inline fun <reified T : AppCompatActivity> Context.createIntent(): Intent =
|
||||
Intent(this, T::class.java)
|
||||
|
||||
inline fun <reified T : AppCompatActivity> Fragment.createIntent() =
|
||||
requireContext().createIntent<T>()
|
||||
|
||||
}
|
||||
@@ -6,10 +6,6 @@ import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
object DateUtils {
|
||||
fun getDateStamp(): String {
|
||||
val sdf: SimpleDateFormat = getSimpleDateFormat("yyyyMMdd_HHmm")
|
||||
return sdf.format(Date())
|
||||
}
|
||||
|
||||
fun getDateTimeStamp(): String {
|
||||
val sdf: SimpleDateFormat = getSimpleDateFormat("yyyyMMdd_HHmmss")
|
||||
@@ -21,7 +17,7 @@ object DateUtils {
|
||||
return try {
|
||||
val sdfIn = getSimpleDateFormat(formatIn)
|
||||
val sdfOut = getSimpleDateFormat(formatOut)
|
||||
val newDate: Date = sdfIn.parse(this)
|
||||
val newDate = sdfIn.parse(this)
|
||||
sdfOut.format(newDate)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package h_mal.appttude.com.driver.utils
|
||||
|
||||
import h_mal.appttude.com.driver.utils.DateUtils.convertDateStringDatePattern
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class DateUtilsTest {
|
||||
|
||||
@Test
|
||||
fun test_getDateTimeStamp() {
|
||||
val regex1 = "[0-9]{8}_[0-9]{6}".toRegex()
|
||||
val date = DateUtils.getDateTimeStamp()
|
||||
assertTrue(regex1 matches date)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_convertDateStringDatePattern() {
|
||||
val inDate = "12/12/2020"
|
||||
val outDate1 = inDate.convertDateStringDatePattern("dd/MM/yyyy", "yyyyMMdd_HHmmss")
|
||||
val regex1 = "[0-9]{8}_[0-9]{6}".toRegex()
|
||||
assertTrue(regex1 matches outDate1)
|
||||
|
||||
// failed match in
|
||||
val outDate2 = inDate.convertDateStringDatePattern("yyyy-MM-dd HH:mm:ss", "yyyyMMdd_HHmmss")
|
||||
assertFalse(regex1 matches outDate2)
|
||||
assertEquals(inDate, outDate2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_parseDateStringIntoCalender() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_parseCalenderIntoDateString() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user