Apoya a Time.now: Únete a nuestro Plan Premium ¡para una experiencia sin anuncios! Apóyanos: ¡Hazte Premium sin anuncios!
Móvil Guía

Android Time API with Kotlin

Android developers often use Retrofit for networking. Here is a simple interface definition to consume the Time.Now API and map it to a data class.

KOTLIN
data class TimeResponse(
    val datetime: String,
    val timezone: String,
    val unixtime: Long
)

interface TimeApiService {
    @GET("timezone/{area}/{location}")
    suspend fun getTime(
        @Path("area") area: String,
        @Path("location") location: String
    ): TimeResponse
}

// Usage inside a Coroutine
val time = api.getTime("America", "New_York")
Log.d("API", "NYC Time: ${time.datetime}")

¿Por qué usar Time.Now para Móvil?

  • Coroutine support
  • Clean architecture
  • Type-safe response
Referencia de la API Ver todas las guías