Browse Source

Added parsing dates from server

sirekanyan 7 years ago
parent
commit
e7fbd6d2a2

+ 6 - 1
app/src/main/java/me/vadik/knigopis/App.kt

@@ -13,6 +13,7 @@ import retrofit2.converter.gson.GsonConverterFactory
 
 private const val MAIN_API_URL = "http://api.knigopis.com"
 private const val IMAGE_API_URL = "https://api.qwant.com/api/"
+private const val DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"
 
 class App : Application() {
 
@@ -20,7 +21,11 @@ class App : Application() {
         Retrofit.Builder()
             .baseUrl(MAIN_API_URL)
             .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
-            .addConverterFactory(GsonConverterFactory.create())
+            .addConverterFactory(
+                GsonConverterFactory.create(
+                    GsonBuilder().setDateFormat(DATE_FORMAT).create()
+                )
+            )
             .client(
                 OkHttpClient.Builder()
                     .setDebugEnabled(BuildConfig.DEBUG)

+ 3 - 0
app/src/main/java/me/vadik/knigopis/model/note/Note.kt

@@ -1,9 +1,12 @@
 package me.vadik.knigopis.model.note
 
+import java.util.*
+
 class Note(
     val id: String,
     val title: String,
     val author: String,
     val notes: String,
+    val createdAt: Date,
     val user: Identity
 )