Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

351
Vistas
Kotlin js/jvm format templates

I am looking for an ability to describe format templates (eg. used in java.util.Formatter) for dates (like java.text.SimpleDateFormat) and numbers (like java.text.DecimalFormat) that could be transparently used to format values both on the backend (jvm) side and on the browser (js) side.

I hoped that kotlin can provide this feature, but my research stopped at feature requests like https://youtrack.jetbrains.com/issue/KT-21644. So as I see I can not get something ready to use with current kotlin version 1.5.31.

So my question is about some posible format template standarts or may be external libraries which can help me to format number and date values in a single approach on backend and frontend side. What I might need to pay attention to get single format template engine?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

For date formatting maybe https://github.com/Kotlin/kotlinx-datetime could help.

At the moment probably is no complete solution for your problem (could you perhaps provide more detail on what you're trying to do? Date Formatting and Decimal Formatting or a common way to format?), one thing you could do is:

  • Redefine Formatter in your common code in a non jvm way as an expected declaration.
  • Define actual implementations for js and jvm (on the jvm side you could probably use typealiases that way you practically get the effect of redefining the actual implementation for js)

Here is an example on how that's done for Android and iOS. Alternatively this blog could offer some inspiration for the typealias part: https://nrobir.medium.com/uploading-images-in-kotlin-multiplatform-ecf87e866505

about 4 years ago · Juan Pablo Isaza Denunciar

0

I am testing now in our commercial projects the Java.format/sprintf-like multiplatform library I wrote to have it working the same in JS, native and JVM. It supports JS Date(), multimplatform lotlinx.datetime and most native datetime formats in JVM, in addition to string/number formatting. Your welcome: https://github.com/sergeych/mp_stools.

It has a almost full set of %t* formats for date/time processing and could be added as a dependency (also MP).

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda