-1

I use the Faker library to generate a phone number. How to configure the generation so that the number is output in the format +7916xxxxxxxx

Faker faker = new Faker(new Locale("ru", "Moscow"));
String phone = faker.phoneNumber().cellPhone();

I put the location on the desired segment, but the wrong format comes to the place of the phone number according to the type 999.000.999

Laplas
  • 91
  • 5

1 Answers1

0

Calling phoneNumber() gives the correct Russian format.

Locale locale = new Locale("ru");
Faker faker = new Faker(locale);
System.out.println(faker.phoneNumber().phoneNumber());
// +7(979)761-86-72

The cell_phone format has not been added in the Russia's locale file, only phone_number.

So, we can use the above method to generate Russia phone numbers.

Note: Looks like Moscow has different format for Phone Number. I guess, there is no city-wise formatting in Faker.

Shri Hari L
  • 4,551
  • 2
  • 6
  • 18