37 lines
913 B
Java
37 lines
913 B
Java
|
|
import java.time.LocalDate;
|
|
import java.util.Random;
|
|
|
|
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
|
*/
|
|
|
|
/**
|
|
*
|
|
* @author 1121947
|
|
*/
|
|
public class Sample {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
int currentYr= LocalDate.now().getYear();
|
|
String yrPrfx = String.valueOf(currentYr);
|
|
|
|
Random random = new Random();
|
|
long digits = (long) (random.nextDouble() * 1_000_000_000_00L); // Generates up to 11 digits
|
|
|
|
// Combine year prefix with random 11 digits
|
|
String randomNumber = yrPrfx + String.format("%011d", digits);
|
|
|
|
System.out.println("The digit is : "+ randomNumber);
|
|
|
|
//return Long.parseLong(randomNumber);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|