File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
AgeInMinutes/app/src/main
java/com/example/ageinminutes Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,25 @@ class MainActivity : AppCompatActivity() {
4242 // get the reference of the text view
4343 val showSelectedDate = findViewById<TextView >(R .id.tvSelectedDate)
4444 // get the values form selected date
45- showSelectedDate.setText( selectedDate)
45+ showSelectedDate.text = selectedDate
4646 // converting the date into a standard format
4747 val formatDate = SimpleDateFormat (" dd/MM/yyyy" , Locale .ENGLISH )
4848 // storing the format date
4949 val theDate = formatDate.parse(selectedDate)
50+ // converting the date into minutes
51+ val selectedDateInMinutes = theDate!! .time / 6000
52+
53+ // format the date into minuest
54+ val currentDate = formatDate.parse(formatDate.format(System .currentTimeMillis()))
55+
56+ // calculate the date in minutes
57+ val currentDateToMinutes = currentDate!! .time / 6000
58+ // difference in minutes
59+ val differenceInMinutes = currentDateToMinutes - selectedDateInMinutes
60+ // get the reference of the text view
61+ val showInMinutes = findViewById<TextView >(R .id.tvSelectedDateInMinutes)
62+ showInMinutes.text = differenceInMinutes.toString()
63+
5064 },
5165 year,
5266 month,
Original file line number Diff line number Diff line change 7070 android : layout_width =" wrap_content"
7171 android : layout_height =" wrap_content"
7272 android : layout_marginTop =" 20dp"
73- android : textColor =" @color/teal_200 "
73+ android : textColor =" @color/purple_700 "
7474 android : textSize =" 35sp"
7575 android : textStyle =" normal" />
7676
You can’t perform that action at this time.
0 commit comments