Convert DateFormats to Kotlin

Starting to convert to Kotlin the whole org.jsoron.uhabits.core.utils
package. First is DateFormats.
pull/699/head
MarKco 5 years ago
parent a74a4b390b
commit d49916263a

@ -17,31 +17,29 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.isoron.uhabits.core.utils; package org.isoron.uhabits.core.utils
import androidx.annotation.*; import java.text.SimpleDateFormat
import java.util.Locale
import java.util.TimeZone
import java.text.*; class DateFormats {
import java.util.*;
public class DateFormats companion object {
{
@NonNull
public static SimpleDateFormat fromSkeleton(@NonNull String skeleton,
@NonNull Locale locale)
{
SimpleDateFormat df = new SimpleDateFormat(skeleton, locale);
df.setTimeZone(TimeZone.getTimeZone("UTC"));
return df;
}
public static SimpleDateFormat getBackupDateFormat() @JvmStatic fun fromSkeleton(
{ skeleton: String,
return fromSkeleton("yyyy-MM-dd HHmmss", Locale.US); locale: Locale
): SimpleDateFormat {
val df = SimpleDateFormat(skeleton, locale)
df.timeZone = TimeZone.getTimeZone("UTC")
return df
} }
public static SimpleDateFormat getCSVDateFormat() @JvmStatic fun getBackupDateFormat(): SimpleDateFormat =
{ fromSkeleton("yyyy-MM-dd HHmmss", Locale.US)
return fromSkeleton("yyyy-MM-dd", Locale.US);
@JvmStatic fun getCSVDateFormat(): SimpleDateFormat =
fromSkeleton("yyyy-MM-dd", Locale.US)
} }
} }
Loading…
Cancel
Save