- 浏览: 4820 次
- 性别:
最新评论
文章列表
Java获取当月第一天
public static String getFirstDay() {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
Date theDate = calendar.getTime();
GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance ...
多表连接查询条件中,判断字符串长度后是否拼接作为条件
select * from t_eds z left join t_causer b
on case when length(z.signature)=3 then '0'||z.signature else z.signature end = b.usercode
想获取前几天的日期,替换数字。
select to_char((sysdate-INTERVAL '5' day),'yyyy-mm-dd') from dual;
MySQL循环插入数据:ID已经添加随机数(可以批量插入测试数据,省的一个一个的麻烦。)
DROP PROCEDURE IF EXISTS proc_initData;
DELIMITER $
CREATE PROCEDURE proc_initData()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i<=50 DO -- 修改成你打算插入的数据条数
INSERT INTO `project` VALUES (CONCAT("项目名称", CEILING(RAND() * 9000 + 1 ...
delimiter $$
CREATE function rs(n int)
returns varchar(1024)
begin
declare chars char(62) default 'abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ0123456789';
declare res varchar(1024) default '';
declare i int default 0;
repeat
set i = i + 1;
set res = concat(res,substring(chars,floo ...
public String getNumId() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
Date now = new Date();
String nowString = sdf.format(now);
Random random = new Random();
int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;
re ...
/**
* 获取随机数4位
* @return
*/
public static String getRandomNumber(){
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < 4; i++){
int num = (int) (Math.random() * 10);
buffer.append(num);
}
return buffer.toString();
}
/**
* 向文件中写入内容
* @param file
* @param content
* @param addFlag
* @throws UtilException
*/
public static void addContentToFile(File file,String content,boolean addFlag) throws UtilException{
try {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss ...
获取文件大小 单位M
- 博客分类:
- Java
/**
* 获取文件大小 单位M
* @param file
* @return
* @throws UtilException
*/
public static double getFileSize(File file) throws UtilException{
try {
double size=0;
if (file.exists()) {
FileInputStream fis = null;
fis = new FileInputStream(file);
...
public static void main(String[] args) {
int randomMax = 999999;
int randomMin = 100000;
int radomInt = randomMin + new Random().nextInt(randomMax - randomMin);
System.out.println(radomInt);
int radomInt2 = new Random().nextInt(99999);
System.out.println(radomInt2);
}