随机数
int random = (int)(Math.random()*1000000);//六位随机整数
Random random = new Random();
random.nextInt(10);//0-9之间的随机数
JSONObject&JSONArray
反射
/**
* 该方法通过反射可以调用项目中的所有的私有方法
* @param className 包名加类名
* @param methodName 方法名
* @param params 方法参数
* @param type 方法参数类型
* @return
* @throws Exception
*/
public static Object getPrivateMethod(String className, String methodName, Object[] params, Class<?>...type) throws Exception{
Class aClass = Class.forName(className);
Object person = aClass.newInstance();
Method randomNum = aClass.getDeclaredMethod(methodName,type);
randomNum.setAccessible(true);
Object invoke = randomNum.invoke(person,params);
return invoke;
}
}
Object random = getPrivateMethod("com.dlsx.demo.Person","a",new Object[]{4,"a"},int.class,String.class);
微服务
- 一个应用应该是由一组小型服务,通过http的方式进行沟通
url地址中文乱码
encodeURI()
时间
LocalDateTime sendTime = LocalDateTime.now();//获取现在时间
LocalDateTime time=sendTime.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);//今晚十二点
if(Duration.between(sendTime, time).toDays() < 1)//现在时间到发送时间的天数<1天