Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Created March 21, 2018 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyoshikawa1106/70a2ba291a040f0411d8001d9268697d to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/70a2ba291a040f0411d8001d9268697d to your computer and use it in GitHub Desktop.
Apex Get Random Value
public with sharing class CommonUtil {
/**
* ランダム値取得
*/
public static Integer getRandomNumber(Integer upperLimit) {
if (upperLimit == null || upperLimit <= 0) {
return 0;
}
Integer rand = Math.round(Math.random()*1000);
return Math.mod(rand, upperLimit);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment