Commit 94aa7288 authored by 邢足健's avatar 邢足健

coding

parent e1507e68
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://haomo-tech.com:3317/org?useUnicode=true&characterEncoding=UTF8 jdbc.url=jdbc:mysql://haomo-tech.com:3317/org?useUnicode=true&characterEncoding=UTF8
jdbc.username=root jdbc.username=org
jdbc.password=root jdbc.password=org@haomo
\ No newline at end of file \ No newline at end of file
package com.haomostudio.SpringMVCTemplate.controller;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;
public class test1Controller {
//读取json文件
public static Boolean reader(String filePath, String outPath) {
BufferedReader reader = null;
String laststr = "";
try {
FileInputStream fileInputStream = new FileInputStream(filePath);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
reader = new BufferedReader(inputStreamReader);
String tempString = null;
FileWriter out = new FileWriter(outPath);
BufferedWriter bw = new BufferedWriter(out);
while ((tempString = reader.readLine()) != null) {
String s = sqlString(tempString);
bw.write(s);
bw.newLine();
}
bw.flush();
bw.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return true;
}
public static String sqlString(String str) {
String modl_uuid = getUUID();
String woe_key = StringUtils.substringBefore(str, "|");
String s1 = StringUtils.substringBeforeLast(str, "|");
String woe_typ = s1.substring(s1.lastIndexOf("|") + 1);
String woe_info = str.substring(str.lastIndexOf("|") + 1).replace("\"","\\\"");
String woe_crt_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
String woe_upd_time = null;
String woe_creator = "admin";
String woe_updater = null;
String sqlString = "insert into `md_woe` (`modl_uuid`, `woe_key`, `woe_dsc`, `woe_typ`, `woe_info`, `woe_crt_time`, `woe_upd_time`, `woe_creator`, `woe_updater`) values('" + modl_uuid + "','" + woe_key + "','" + woe_key + "','" + woe_typ + "','" + woe_info + "','" + woe_crt_time + "'," + woe_upd_time + ",'" + woe_creator + "'," + woe_updater + ");";
return sqlString;
}
public static String getUUID() {
return UUID.randomUUID().toString().trim().replaceAll("-", "");
}
public static void main(String[] args) throws ParseException {
;//设置日期格式
String format = "HH:mm:ss";
Date nowTime = new SimpleDateFormat(format).parse(new SimpleDateFormat("HH:mm:ss").format(new Date()));
Date startTime = new SimpleDateFormat(format).parse("09:00:00");
Date endTime = new SimpleDateFormat(format).parse("18:00:00");
System.out.println(isEffectiveDate(nowTime, startTime, endTime));
}
public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
if (nowTime.getTime() == startTime.getTime()
|| nowTime.getTime() == endTime.getTime()) {
return true;
}
Calendar date = Calendar.getInstance();
date.setTime(nowTime);
Calendar begin = Calendar.getInstance();
begin.setTime(startTime);
Calendar end = Calendar.getInstance();
end.setTime(endTime);
if (date.after(begin) && date.before(end)) {
return true;
} else {
return false;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment