mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-121178 Add exception handling and report diagnostics info
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.stats.personalization.impl
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.stats.personalization.Day
|
||||
import java.text.ParsePosition
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -30,11 +31,20 @@ class DayImpl(date: Date) : Day {
|
||||
override val year: Int
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(DayImpl::class.java)
|
||||
private val DATE_FORMAT = SimpleDateFormat("dd-MM-yyyy")
|
||||
|
||||
fun fromString(str: String): Day? {
|
||||
val position = ParsePosition(0)
|
||||
val date = DATE_FORMAT.parse(str, position)
|
||||
|
||||
val date: Date
|
||||
try {
|
||||
date = DATE_FORMAT.parse(str, position)
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
LOG.error("Could not parse a date from string: $str. Collected data for the day will be skipped.")
|
||||
return null
|
||||
}
|
||||
if (position.index == 0) return null
|
||||
return DayImpl(date)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user