본문 바로가기
SpringBoot

how to generate random number or Alphabetic in java

by ByteBridge 2020. 4. 30.
반응형

apache.commons-lang3

compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'

tutorial - generate sample code:

//[a-zA-Z] -> RandomStringUtils.randomAlphabetic(count)
//[0-9] -> RandomStringUtils.randomNumeric(count)
//[a-zA-Z0-9] -> RandomStringUtils.randomAlphanumeric(count)

String.format("%s-%s-%s", RandomStringUtils.randomAlphabetic(5),
                RandomStringUtils.randomNumeric(5),
                RandomStringUtils.randomAlphanumeric(5)).toUpperCase();

output: OYNED-01202-GW424

반응형

'SpringBoot' 카테고리의 다른 글

Spring boot kafka demo with docker-compose  (0) 2020.07.20
Flux and Mono  (0) 2020.07.14
Object List multiple field compare and remove  (0) 2020.02.25
Java Object Stream group by multiple field and map in map to list  (0) 2020.01.05
JPA - Join  (0) 2019.12.08