语言用的是kotlin,和Java类似

        var time = ""
        val sdf1 = SimpleDateFormat("yyyy/MM/dd")
        val sdf2 = SimpleDateFormat("kk:mm")
        time = sdf1.format(this.dateStart) + " " +   sdf2.format(this.timeStart)

首先定义SimpleDateFormat,然后传入想要的格式,再利用对象的format函数,将任意关于时间类型的参数放进去,得到的即是想要的格式。

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案