我的应用程序在我拍摄日期后关闭,任何人都可以帮助我,我已经附上代码

My app is closing after i pic the date , can anyone help me , i have attatched the code

这是我的代码,它在我 select 日期选择器对话框中的日期后崩溃

bdaybutton.setOnClickListener { view -\\>

    val c = Calendar.getInstance()
    val cyear = c.get(Calendar.YEAR)
    val cmonth = c.get(Calendar.MONTH)
    val cday = c.get(Calendar.DAY_OF_MONTH)

    val abc = DatePickerDialog(  this , DatePickerDialog.OnDateSetListener
    { view , year, month, day -\\>

        flag2 = true
        year2 = year
        val selecteddate = "${day/month+1/year}"
        bdaydatetext.text = "${day/month+1/year}"
        val sdf = java.text.SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH)
        val date2 = sdf.parse(selecteddate)
        time2 = date2.time.toInt()

    }, cyear, cmonth, cday)

    abc.show()

]

}

select输入日期

后图像出现错误
"${day/month+1/year}"

这会计算 {} 中的表达式并将其转换为字符串。看起来你想要像

这样的东西
"${day}/${month+1}/${year}"

而不是那里。

更好的是,完全跳过字符串转换步骤,直接使用 Java 8 LocalDateLocalDateTime 之类的东西。