Giter Club home page Giter Club logo

Comments (6)

serpro69 avatar serpro69 commented on May 14, 2024 1

Take a look at RandomService class. Initially I didn't think it would be useful to have it public since mostly what it does is wrapping around java.util.Random. But I don't see any reason not to expose it from Faker class, for example, if it can be useful.

You could do something like:

val intAmount = faker.randomService.nextInt(1, 100) // returns a random int from 1 to 100
val moneyAmount = "$$intAmount"

Different monetary signs like $, , ¥, et al., can be supported through a separate function if that's of any interest as well.

from kotlin-faker.

serpro69 avatar serpro69 commented on May 14, 2024

Hi.
Can you give an example of what function you are calling and what output you expect?

from kotlin-faker.

kdani41 avatar kdani41 commented on May 14, 2024

Some function that can help creating random amount.

So is something like this possible?

faker.amount(Locale.US) - $123,312,123

from kotlin-faker.

kdani41 avatar kdani41 commented on May 14, 2024

Thanks for this but i think I will have to end up using a currency formatter that formats the value correctly because in the end the result should look something like this $125,212,212.04

from kotlin-faker.

serpro69 avatar serpro69 commented on May 14, 2024

A random number with a floating point can also be generated by RandomService class.
But from what I understood, you also need a "thousands separator" (in your example it's a , but I think it should be configurable as well) ?
In that case a new function can be added (probably to Finance provider, unless I find a better place for it), that puts all of this together.

from kotlin-faker.

serpro69 avatar serpro69 commented on May 14, 2024

Closed with 2e3daea

@kdani41 FYI.

For now only $ currency sign is supported irrespective of selected locale. This can be further enhanced to support locale-based currency signs, which only requires changes to the localized yml dict files. Feel free to make a PR or open another issue for that.

from kotlin-faker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.