Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

357
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda