}
// Report the first 5 children, to give a flavour
- int upTo = 5;
- if(children.length < 5) { upTo = children.length; }
+ int upTo = Math.min(children.length, 5);
for(int k=0; k<upTo; k++) {
Record r = children[k];
int typeID = (int)r.getRecordType();
}
private static IOException alertShortRead(int pRead) {
- int read;
- if (pRead < 0) {
- //Can't have -1 bytes read in the error message!
- read = 0;
- } else {
- read = pRead;
- }
+ int read = Math.max(pRead, 0);
+ //Can't have -1 bytes read in the error message!
String type = " byte" + (read == 1 ? (""): ("s"));
return new IOException("Unable to read entire header; "
*/
protected int pastDaysOfWeek(double start, double end, int dayOfWeek) {
int pastDaysOfWeek = 0;
- int startDay = (int) Math.floor(start < end ? start : end);
- int endDay = (int) Math.floor(end > start ? end : start);
+ int startDay = (int) Math.floor(Math.min(start, end));
+ int endDay = (int) Math.floor(Math.max(end, start));
for (; startDay <= endDay; startDay++) {
Calendar today = LocaleUtil.getLocaleCalendar();
today.setTime(DateUtil.getJavaDate(startDay));
*/
protected int calculateNonWeekendHolidays(double start, double end, double[] holidays) {
int nonWeekendHolidays = 0;
- double startDay = start < end ? start : end;
- double endDay = end > start ? end : start;
+ double startDay = Math.min(start, end);
+ double endDay = Math.max(end, start);
for (double holiday : holidays) {
if (isInARange(startDay, endDay, holiday)) {
if (!isWeekend(holiday)) {
}
DecimalFormat nf = (DecimalFormat) NumberFormat.getCurrencyInstance(LocaleUtil.getUserLocale());
- int decimalPlaces = nPlaces < 0 ? 0 : nPlaces;
+ int decimalPlaces = Math.max(nPlaces, 0);
if (LocaleUtil.getUserLocale().getCountry().equalsIgnoreCase("US")) {
nf.setNegativePrefix("(" + nf.getDecimalFormatSymbols().getCurrencySymbol());
nf.setNegativeSuffix(")");
}
} else if (m.group(1) != null) {
int len = m.group(1).length();
- len = len > MAX_DENOM_POW ? MAX_DENOM_POW : len;
+ len = Math.min(len, MAX_DENOM_POW);
tmpMax = (int)Math.pow(10, len);
} else {
tmpExact = 100;