2022-05-01 19:48:52 +00:00
|
|
|
package com.alttd.altitudequests.util;
|
|
|
|
|
|
2022-06-02 20:12:29 +00:00
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
2022-06-01 17:33:02 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
2022-05-01 19:48:52 +00:00
|
|
|
public class Utilities {
|
|
|
|
|
public static double round(double num, int precision) {
|
|
|
|
|
double scale = Math.pow(10, precision);
|
|
|
|
|
return ((int) (num * scale)) / scale;
|
|
|
|
|
}
|
2022-06-01 17:33:02 +00:00
|
|
|
|
|
|
|
|
public static int randomOr0(int max) {
|
|
|
|
|
if (max <= 1)
|
|
|
|
|
return 0;
|
2022-09-05 17:28:37 +00:00
|
|
|
return new Random().nextInt(0, max);
|
2022-06-01 17:33:02 +00:00
|
|
|
}
|
2022-06-02 20:12:29 +00:00
|
|
|
|
|
|
|
|
public static int getYearDay() {
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
calendar.setTime(new Date());
|
|
|
|
|
return (calendar.get(Calendar.YEAR) * 1000) + calendar.get(Calendar.DAY_OF_YEAR);
|
|
|
|
|
}
|
2022-06-03 00:50:44 +00:00
|
|
|
|
|
|
|
|
public static String formatName(String name) {
|
|
|
|
|
name = name.toLowerCase().replaceAll("_", " ");
|
|
|
|
|
return name.replace(name.charAt(0), Character.toUpperCase(name.charAt(0)));
|
|
|
|
|
}
|
2022-05-01 19:48:52 +00:00
|
|
|
}
|