All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.datafaker.providers.base.PhoneNumber Maven / Gradle / Ivy

Go to download

This library is a improved port of JavaFaker (as well as Ruby's stympy/faker gem and Perl's Data::Faker library) that generates fake data. It's useful when you're developing a new project and need some pretty data for showcase.

There is a newer version: 2.4.2
Show newest version
package net.datafaker.providers.base;

/**
 * @since 0.8.0
 */
public class PhoneNumber extends AbstractProvider {

    protected PhoneNumber(BaseProviders faker) {
        super(faker);
    }

    public String cellPhone() {
        return faker.numerify(resolve("cell_phone.formats"));
    }

    /**
     * Generates locale specific phone number in national format.
     *
     * @return phone number
     */
    public String phoneNumber() {
        return phoneNumberNational();
    }

    public String phoneNumberInternational() {
        return faker.numerify(resolve("phone_number.formats_international"));
    }

    public String phoneNumberNational() {
        return faker.numerify(resolve("phone_number.formats"));
    }

    public String extension() {
        return subscriberNumber();
    }

    public String subscriberNumber(int length) {
        return faker.numerify("#".repeat(Math.max(0, length)));
    }

    public String subscriberNumber() {
        return subscriberNumber(4);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy