Forgive my lack of knowledge, as I am correcting code to give me the correct numbers from a database. I am normally using java, but was given this file in .kt
val Time: Date,
val duration: Long,
val rate: Long
){
constructor():this(Date(),0,0)
}
@Composable
fun SessionContainer(sessionList: MutableList<MSession>) {
var totalM = 0f
var totalMi = 0f
var mSessions = 0
sessionList.forEach {
if (it.completionTime.time < Calendar.getInstance().time.time)
totalM += it.rate * (it.duration / 1000 / 60 / 60)
else{
totalMi += it.rate * (it.duration / 1000 / 60 / 60)
mSessions++
}
}
Column(
Modifier
.fillMaxWidth()
.padding(12.dp)
) {
Text(text = "Total M [${totalM.toDouble()}]", fontWeight = FontWeight.Bold)
Text(text = "Total Mi [${totalMi.toDouble()}] in total $mSessions sessions", fontWeight = FontWeight.Bold)
}
}
The information in the database is in decimal format. I just need to be able to display it and I do not know how to code kotlin. I made a change already that is now displays "0.0" instead of "0", but there should be a number with those decimals(i.e. 123.4567)