Hello everyone,
I need to create a a simple java function where I can put start and end datum in the format 201901 up to 202052
that means every year have got 52 week. so the randomizer put a value between year 2019 and 2020. also a week between 01 to 52.
and the format need to look like
201901
my atempt is below but how do I keep the leading zero ?
Thank you in advance
I need to create a a simple java function where I can put start and end datum in the format 201901 up to 202052
that means every year have got 52 week. so the randomizer put a value between year 2019 and 2020. also a week between 01 to 52.
and the format need to look like
201901
my atempt is below but how do I keep the leading zero ?
Java:
public static void main(String[]args)
{
public static void main(String[]args)
{
int weekMin=01;
int weekMax=52;
int YearMin=2019;
int YearMax=2020;
int randomWeek = ThreadLocalRandom.current().nextInt(weekMin, weekMax + 1);
int randomYear = ThreadLocalRandom.current().nextInt(YearMin, YearMax + 1);
String Week = String.format("%02d", randomWeek);
System.out.println(randomYear+""+Week);
}
}
Thank you in advance