라이브 상세 UTC 시작 시간 반영
라이브 상세 응답에 beginDateTimeUtc 필드를 사용해 로컬 시간으로 표시한다.
This commit is contained in:
@@ -19,6 +19,7 @@ data class GetRoomDetailResponse(
|
||||
@SerializedName("tags") val tags: List<String>,
|
||||
@SerializedName("channelName") val channelName: String?,
|
||||
@SerializedName("beginDateTime") val beginDateTime: String,
|
||||
@SerializedName("beginDateTimeUtc") val beginDateTimeUtc: String,
|
||||
@SerializedName("isNotification") val isNotification: Boolean,
|
||||
@SerializedName("numberOfParticipants") val numberOfParticipants: Int,
|
||||
@SerializedName("numberOfParticipantsTotal") val numberOfParticipantsTotal: Int,
|
||||
|
||||
@@ -26,10 +26,11 @@ import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentLiveRoomDetailBinding
|
||||
import kr.co.vividnext.sodalive.databinding.ItemLiveDetailUserSummaryBinding
|
||||
import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
|
||||
import kr.co.vividnext.sodalive.extensions.convertDateFormat
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class LiveRoomDetailFragment(
|
||||
private val roomId: Long,
|
||||
@@ -123,9 +124,10 @@ class LiveRoomDetailFragment(
|
||||
}
|
||||
|
||||
binding.tvTitle.text = response.title
|
||||
binding.tvDate.text = response.beginDateTime.convertDateFormat(
|
||||
from = "yyyy.MM.dd EEE hh:mm a",
|
||||
to = getString(R.string.screen_live_room_detail_date_format)
|
||||
binding.tvDate.text = formatUtcToLocal(
|
||||
utcDateString = response.beginDateTimeUtc,
|
||||
fromFormat = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
toFormat = getString(R.string.screen_live_room_detail_date_format)
|
||||
)
|
||||
|
||||
if (response.price > 0) {
|
||||
@@ -366,4 +368,26 @@ class LiveRoomDetailFragment(
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatUtcToLocal(
|
||||
utcDateString: String,
|
||||
fromFormat: String,
|
||||
toFormat: String
|
||||
): String {
|
||||
val fromDateFormat = SimpleDateFormat(fromFormat, Locale.getDefault())
|
||||
fromDateFormat.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val toDateFormat = SimpleDateFormat(toFormat, Locale.getDefault())
|
||||
toDateFormat.timeZone = TimeZone.getDefault()
|
||||
|
||||
return try {
|
||||
val date = fromDateFormat.parse(utcDateString)
|
||||
if (date != null) {
|
||||
toDateFormat.format(date)
|
||||
} else {
|
||||
utcDateString
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
utcDateString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user