Created
March 21, 2018 06:35
-
-
Save tyoshikawa1106/70a2ba291a040f0411d8001d9268697d to your computer and use it in GitHub Desktop.
Apex Get Random Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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