Skip to content

Commit

Permalink
Merge pull request #20828 from wordpress-mobile/issue/20826-NPE-getTime
Browse files Browse the repository at this point in the history
Fix NPE on Publish Settings screen
  • Loading branch information
irfano committed May 17, 2024
2 parents a32269a + a20e6a2 commit f83cca4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.wordpress.android.util.LocaleManagerWrapper
import org.wordpress.android.viewmodel.Event
import org.wordpress.android.viewmodel.ResourceProvider
import java.util.Calendar
import java.util.Date

abstract class PublishSettingsViewModel
constructor(
Expand Down Expand Up @@ -212,7 +213,10 @@ constructor(
val dateCreated = postRepository.dateCreated
// Set the currently selected time if available
if (!TextUtils.isEmpty(dateCreated)) {
calendar.time = DateTimeUtils.dateFromIso8601(dateCreated)
// Calendar.setTime(Date date) expects a non-null Date object
val maybeDate: Date? = DateTimeUtils.dateFromIso8601(dateCreated)
maybeDate?.let { date -> calendar.time = date }

calendar.timeZone = localeManagerWrapper.getTimeZone()
}
return calendar
Expand Down

0 comments on commit f83cca4

Please sign in to comment.