import java.text.SimpleDateFormat

// Define date format
val inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S")
val outputFormat4y = new SimpleDateFormat("dd/MM/yyyy")
val outputFormat4Y = new SimpleDateFormat("dd/MM/YYYY")

// Tests
//-- CASE ONE : normal date
println("CASE 1 (yyyy) : " + outputFormat4y.format(inputFormat.parse("2022-01-10 12:34:00.0"))) // => 2022
println("CASE 1 (YYYY) : " + outputFormat4Y.format(inputFormat.parse("2022-01-10 12:34:00.0"))) // => 2022

//-- CASE TWO : end of year date
println("CASE 2 (yyyy) : " + outputFormat4y.format(inputFormat.parse("2021-12-29 14:56:00.0"))) // => 2021
println("CASE 2 (YYYY) : " + outputFormat4Y.format(inputFormat.parse("2021-12-29 12:56:00.0"))) // => 2022 /!\