Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

358
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!