πμ°Έκ³ λ¬Έμ
λλ©μΈ λ μ΄μ΄μ κ΅¬μ± ν΄λμ€:
μ¬μ© μ¬λ‘ ν΄λμ€ μ:
class FormatDateUseCase(userRepository: UserRepository) {
private val formatter = SimpleDateFormat(
userRepository.getPreferredDateFormat(),
userRepository.getPreferredLocale()
)
operator fun invoke(date: Date): String {
return formatter.format(date)
}
}
class MyViewModel(formatDateUseCase: FormatDateUseCase) : ViewModel() {
init {
val today = Calendar.getInstance()
val todaysDate = formatDateUseCase(today)
/* ... */
}
}