DateFormatUtils.format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
DateUtils.parseDate("20120617", new String[] {"yyyyMMdd", "yyyyMM"});
下载maven安装包资源:
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
mvn -v
rpm -qa|grep java
rpm -qa|grep jdk
rpm -e --nodeps ${系统jdk名}
安装
wget https://d6.injdk.cn/oracle/8/jdk-8u251-linux-x64.rpm
rpm -ivh jdk-8u251-linux-x64.rpm
各版本JDK: https://www.injdk.cn/
curl -sSL https://get.daocloud.io/docker | sh
curl -L https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
public static void main(String[] args)
{
List<String> list = new ArrayList<String>();
while (RandomUtils.nextInt() > 9999999)
{
list.add(RandomStringUtils.randomAscii(5));
}
System.out.println(list);
System.out.println(list.size());
while (list.size() > 10)
{
List<String> it = list.subList(0, 10);
System.out.println(list.size() + ":\t" + it);
list.removeAll(it);
}
System.out.println(list.size() + ":\t" + list);
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
/**
*
* 日志定时任务
*
* @author 00fly
* @version [版本号, 2019年12月30日]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
@Slf4j
@Component
public class LogJob
{
@Autowired
private SysLogService sysLogService;
/**
* 推送日志信息到3rd 9-22点每30分钟执行一次
*
* @see [类、类#方法、类#成员]
*/
@Scheduled(cron = "0 0/30 9-22 * * ? ")
public void push()
{
try
{
log.info("★★★★★★★★★ now push Log ★★★★★★★ ");
Map<String, Object> params = new HashMap<String, Object>();
// 批量推送未同步日志信息
int pageNo = 1, pageSize = 1000;
params.put(Constant.LIMIT, pageSize);
params.put("channel", "PUYUAN");// 3rd
params.put("dataSyn", "0"); // 待同步
PageUtils data;
do
{
log.info("★★★★★★★★★ now push pageNo={}, pageSize={}", pageNo, pageSize);
params.put(Constant.PAGE, pageNo++);
data = sysLogService.queryPage(params);
List<SysLogEntity> list = (List<SysLogEntity>)data.getList();
// TODO: 我方作为客户端将数据推送到3rd,3rd处理成功后返回已处理id列表,更新数据同步成功状态
for (SysLogEntity entity : list)
{
log.info("****{}*****", entity);
}
TimeUnit.MINUTES.sleep(2);
} while (data.getTotalCount() > 0);
}
catch (Exception e)
{
log.error("★★★★★★★★★ now push Log Error: {} ★★★★★★★ ", e.getCause());
}
}
}
@Test
public void test()
{
Scanner sc = new Scanner(System.in);
do
{
logger.info("{}", mockMvc);
logger.info("------------输入x退出,回车换行继续------------");
} while (!StringUtils.equalsIgnoreCase(sc.nextLine(), "x"));
logger.info("------------成功退出------------");
sc.close();
}
String.format("%.nf",d); //表示保留N位!