本文整理汇总了Java中com.xnx3.DateUtil类的典型用法代码示例。如果您正苦于以下问题:Java DateUtil类的具体用法?Java DateUtil怎么用?Java DateUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateUtil类属于com.xnx3包,在下文中一共展示了DateUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportTemplate
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 导出当前网站当前的模版文件,包含模版页面,模版变量、栏目
* @throws FileNotFoundException
* @throws UnsupportedEncodingException
*/
@RequestMapping("exportTemplate")
public void exportTemplate(HttpServletRequest request, HttpServletResponse response) throws FileNotFoundException, UnsupportedEncodingException {
BaseVO vo = templateService.exportTemplate(request);
String fileName = "template"+DateUtil.currentDate("yyyyMMdd_HHmm")+".wscso".toString(); // 文件的默认保存名
//读到流中
InputStream inStream = new ByteArrayInputStream(vo.getInfo().getBytes("UTF-8"));
AliyunLog.addActionLog(getSiteId(), "导出当前网站当前的模版文件");
// 设置输出的格式
response.reset();
response.setContentType("bin");
response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
// 循环取出流中的数据
byte[] b = new byte[1000];
int len;
try {
while ((len = inStream.read(b)) > 0)
response.getOutputStream().write(b, 0, len);
inStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: TemplateCMS
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 默认editMode为生成模式
* @param site
*/
public TemplateCMS(Site site) {
linuxTime = DateUtil.timeForUnix10();
this.site = site;
if(Global.get("MASTER_SITE_URL") != null && Global.get("MASTER_SITE_URL").equals("http://wang.market/")){
if(site.getId() - 255 > 0){
//site.id < 255 的站点,是code模式
generateUrlRule = "code";
}
if(site.getId() - 218 == 0){
//site.id 218 是qiye1,作为调试使用
generateUrlRule = "code";
}
}else{
//后台主域名不是wang.market,那可能就是别人在使用这个程序,直接使用code模式生成html文件
generateUrlRule = "code";
}
}
示例3: previewByToken
import com.xnx3.DateUtil; //导入依赖的package包/类
@RequestMapping("previewByToken")
public String previewByToken(HttpServletRequest request,Model model,
@RequestParam(value = "token", required = false , defaultValue="") String token){
//进行安全过滤
token = token.replaceAll("\\s*", "");
token = filter(token);
if(token.length() != 64){
return error(model, "授权码错误");
}else{
int currentTime = DateUtil.timeForUnix10();
int startTime = currentTime - 86400*30; //30天内有效
try {
AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil);
JSONArray jsonArray = log.listForJSONArray("receiveSocketUuid="+token, "", false, startTime, currentTime, 100, request);
model.addAttribute("list", jsonArray);
} catch (LogException e) {
e.printStackTrace();
}
}
return "im/perviewByToken";
}
示例4: hostoryChatList
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 历史聊天人列表,会话列表,每一项都是一个人
*/
@RequestMapping("hostoryChatList")
public String hostoryChatList(HttpServletRequest request,Model model){
if(Global.aliyunLogUtil == null){
return error(model, "您未开启IM客服访问相关的日志服务!");
}
User user = getUser();
int currentTime = DateUtil.timeForUnix10();
int startTime = currentTime - 86400*30; //30天内有效
try {
AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil);
JSONArray jsonArray = log.listForJSONArray("receiveId = "+user.getId()+" | select max(sendId) , map_agg('array',sendUserName) as sendUserName,max(sendId) as sendIds, count(*) as count, max(__time__) as time group by sendId order by time desc limit 100", "", false, startTime, currentTime, 100, request);
model.addAttribute("list", jsonArray);
} catch (LogException e) {
e.printStackTrace();
}
return "im/hostoryChatList";
}
示例5: chatRecord
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 聊天记录,跟某个人之间,一个会话的聊天记录,两个人之间的聊天记录
* @param id 跟自己会话的那个人的id,对方的id
*/
@RequestMapping("chatRecord")
public String chatRecord(HttpServletRequest request,Model model,
@RequestParam(value = "id", required = false , defaultValue="0") long id){
if(id == 0){
return error(model, "请输入要查看得对方得id编号");
}
User user = getUser();
int currentTime = DateUtil.timeForUnix10();
int startTime = currentTime - 86400*30; //30天内有效
try {
AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil);
JSONArray jsonArray = log.listForJSONArray("(receiveId = "+user.getId()+" and sendId = "+id+" ) or (receiveId = "+id+" and sendId = "+user.getId()+" )", "", false, startTime, currentTime, 100, request);
JSONArray ja = new JSONArray(); //将其倒序
for (int i = jsonArray.size()-1; i >-1 ; --i) {
ja.add(jsonArray.get(i));
}
model.addAttribute("list", ja);
} catch (LogException e) {
e.printStackTrace();
}
model.addAttribute("user", user);
return "im/chatRecord";
}
示例6: postHandle
import com.xnx3.DateUtil; //导入依赖的package包/类
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
if(useExecuteTime){
long startTime = (Long)request.getAttribute("startTime");
long endTime = System.currentTimeMillis();
long executeTime = endTime - startTime;
if(executeTime > recordTime){
System.out.println(DateUtil.currentDate("MM-dd HH:mm:ss")+" ControllerExecuteTime : "+executeTime+" ms , "+handler);
}
}
super.postHandle(request, response, handler, modelAndView);
}
示例7: cacheCommit
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 手动将 {@link #cacheLog(LogItem)} 缓存中的数据提交到阿里云日志服务中去。若提交成功,便清空缓存。
* <br/>此方法会在 {@link #cacheLog(LogItem)} 向缓存中添加日志时,当达到 {@link #setCacheLogMaxNumber(int)} 设置的缓存最大条数后会自动触发。
* <br/>当然,比如Tomcat停止时,或者其他意外情况,也可以手动调用此处方法触发提交到阿里云日志服务中的命令
* @return {@link PutLogsResponse} 提交返回的结果
* @throws LogException
*/
public PutLogsResponse cacheCommit() throws LogException{
PutLogsResponse r = saveByGroup("", "", logGroupCache);
if(r != null && r.GetRequestId() != null && r.GetRequestId().length() > 0){
//数据提交成功
//清空日志缓存及条数
logGroupCache.clear();
//同步最后提交时间
int currentTime = DateUtil.timeForUnix10(); //当前时间
if(lastSubmitTime < currentTime){
lastSubmitTime = currentTime;
}
}
return r;
}
示例8: simpleList
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 获取当前7天内,最新的100条日志列表
* @throws LogException
*/
public static void simpleList() throws LogException{
int endTime = DateUtil.timeForUnix10(); //结束时间为当前时间
ArrayList<QueriedLog> qList = actionLog.queryList("", "", endTime - (7*24*60*60), endTime, 0, 100, true);
for (int i = 0; i < qList.size(); i++) {
System.out.println(qList.get(i).GetLogItem().ToJsonString());
}
}
示例9: dayLineForCurrentMonth
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 折线图,当月(最近30天),每天的访问情况
*/
@RequiresPermissions("adminRequestLogFangWen")
@RequestMapping("dayLineForCurrentMonth")
@ResponseBody
public RequestLogDayLineVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{
RequestLogDayLineVO vo = new RequestLogDayLineVO();
//当前10位时间戳
int currentTime = DateUtil.timeForUnix10();
String query = "Mozilla | timeslice 24h | count as c";
//当月访问量统计
ArrayList<QueriedLog> jinriQlList = G.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true);
JSONArray jsonArrayDate = new JSONArray(); //天数
JSONArray jsonArrayFangWen = new JSONArray(); //某天访问量,pv
for (int i = 0; i < jinriQlList.size(); i++) {
LogItem li = jinriQlList.get(i).GetLogItem();
JSONObject json = JSONObject.fromObject(li.ToJsonString());
try {
jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd"));
} catch (NotReturnValueException e) {
e.printStackTrace();
}
jsonArrayFangWen.add(json.getInt("c"));
}
vo.setJsonArrayFangWen(jsonArrayFangWen);
vo.setJsonArrayDate(jsonArrayDate);
AliyunLog.addActionLog(0, "总管理后台,获取最近30天的访问数据统计记录");
return vo;
}
示例10: getOSSSize
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 获取用户的OSS已用空间
*/
@RequestMapping("getOSSSize")
@ResponseBody
public BaseVO getOSSSize(){
//判断一下,如果是使用的阿里云OSS存储,但是没有配置,会拦截提示
if(AttachmentFile.isMode(AttachmentFile.MODE_ALIYUN_OSS) && OSSUtil.getOSSClient() == null){
return error("未开通阿里云OSS服务");
}
BaseVO vo = new BaseVO();
//获取其下有多少网站
List<Site> list = sqlService.findBySqlQuery("SELECT * FROM site WHERE userid = "+getUserId(), Site.class);
//属于该用户的这些网站共占用了多少存储空间去
long sizeB = 0;
for (int i = 0; i < list.size(); i++) {
sizeB += AttachmentFile.getDirectorySize("site/"+list.get(i).getId()+"/");
}
int kb = Math.round(sizeB/1024);
String currentDate = DateUtil.currentDate("yyyyMMdd");
sqlService.executeSql("UPDATE user SET oss_update_date = '"+currentDate+"' , oss_size = "+kb+" WHERE id = "+getUserId());
vo.setBaseVO(BaseVO.SUCCESS, kb+"");
AliyunLog.addActionLog(getSiteId(), "计算我当前网站使用了多少存储空间,已使用:"+Lang.fileSizeToInfo(sizeB));
ShiroFunc.setUEditorAllowUpload(kb<ShiroFunc.getUser().getOssSizeHave()*1000);
return vo;
}
示例11: wenTiFanKui
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 问题反馈
*/
@RequestMapping("wenTiFanKui")
@ResponseBody
public BaseVO wenTiFanKui(@RequestParam(value = "text", required = false , defaultValue="") String text){
if(text.length() == 0){
return error("说点什么呢?");
}
Feedback fb = new Feedback();
fb.setAddtime(DateUtil.timeForUnix10());
fb.setUserid(getUserId());
fb.setText(filter(text));
sqlService.save(fb);
if(fb.getId() != null && fb.getId() > 0){
String jianjie = fb.getText();
if(jianjie.length() > 30){
jianjie = jianjie.substring(0, 30);
}
AliyunLog.addActionLog(getSiteId(), "提交问题反馈:"+jianjie);
//发送邮件
MailUtil.sendMail(Global.get("SERVICE_MAIL"), "有新的问题反馈", fb.toString());
return success();
}else{
return error("保存出错!请重试");
}
}
示例12: updateBySiteId
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 计划废弃,修改轮播图时将鼠标放到轮播图上,会自动出现跟随文字指导
* 通过siteid更改carousel图,只限一个站点有一张图的情况, wap模式建站/ (可能pc模式也用到)
*/
@RequestMapping("updateBySiteId")
public String updateBySiteId(HttpServletRequest request,Model model){
Site site = getSite();
Carousel carousel = sqlService.findAloneBySqlQuery("SELECT * FROM carousel WHERE siteid = "+site.getId(), Carousel.class);
if(carousel == null){
//意外情况,正常情况下,轮播图是不能不存在的,这个不存在,那么新建一个
carousel = new Carousel();
carousel.setAddtime(DateUtil.timeForUnix10());
carousel.setIsshow(Carousel.ISSHOW_SHOW);
carousel.setRank(1);
carousel.setSiteid(site.getId());
carousel.setType(Carousel.TYPE_INDEXBANNER);
carousel.setUserid(site.getUserid());
carousel.setImage("");
//记录意外日志
AliyunLog.addActionLog(site.getId(), "warn", "网站id("+site.getId()+")无默认轮播图");
}
String image = carousel.getImage().indexOf("://")==-1? AttachmentFile.netUrl()+"site/"+site.getId()+"/carousel/"+carousel.getImage():carousel.getImage();
// siteService.getTemplateCommonHtml(site, "修改图片", model);
AliyunLog.addActionLog(carousel.getId() != null? carousel.getId():0, "进入修改站点公用的轮播图页面:"+carousel.getUrl());
model.addAttribute("carousel", carousel);
model.addAttribute("imageImage", "<img src=\""+image+"\" height=\"30\">");
model.addAttribute("site", site);
return "carousel/"+getPcOrWapPrefix(request)+"carousel";
}
示例13: dayLineForCurrentMonth
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 折线图,当月(最近30天),每天的访问情况
*/
@RequestMapping("dayLineForCurrentMonth")
@ResponseBody
public RequestLogDayLineVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{
RequestLogDayLineVO vo = new RequestLogDayLineVO();
//当前10位时间戳
int currentTime = DateUtil.timeForUnix10();
String query = "siteid="+getSiteId()+" | timeslice 24h | count as c";
//当月访问量统计
ArrayList<QueriedLog> jinriQlList = G.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true);
JSONArray jsonArrayDate = new JSONArray(); //天数
JSONArray jsonArrayFangWen = new JSONArray(); //某天访问量,pv
for (int i = 0; i < jinriQlList.size(); i++) {
LogItem li = jinriQlList.get(i).GetLogItem();
JSONObject json = JSONObject.fromObject(li.ToJsonString());
try {
jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd"));
} catch (NotReturnValueException e) {
e.printStackTrace();
}
jsonArrayFangWen.add(json.getInt("c"));
}
vo.setJsonArrayFangWen(jsonArrayFangWen);
vo.setJsonArrayDate(jsonArrayDate);
AliyunLog.addActionLog(getSiteId(), "获取最近30天的访问数据统计记录");
return vo;
}
示例14: spiderList
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 爬虫访问列表,列出最近7天内,最近的100条爬虫记录
*/
@RequestMapping("spiderList")
@ResponseBody
public RequestLogItemListVO spiderList(HttpServletRequest request) throws LogException{
RequestLogItemListVO vo = new RequestLogItemListVO();
//当前10位时间戳
int currentTime = DateUtil.timeForUnix10();
String query = "siteid="+getSiteId();
String spider = null;
for (int i = 0; i < spiderNameArray.length; i++) {
if(spider == null){
spider = spiderNameArray[i];
}else{
spider = spider + " or " + spiderNameArray[i];
}
}
query = query + " and ("+spider+")";
//当月访问量统计
ArrayList<QueriedLog> jinriQlList = G.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 604800), currentTime, 0, 100, true);
JSONArray jsonArray = new JSONArray(); //某天访问量,pv
for (int i = 0; i < jinriQlList.size(); i++) {
LogItem li = jinriQlList.get(i).GetLogItem();
JSONObject json = JSONObject.fromObject(li.ToJsonString());
try {
json.put("logtimeString", DateUtil.dateFormat(json.getInt("logtime"), "MM-dd HH:mm"));
} catch (NotReturnValueException e) {
e.printStackTrace();
}
UserAgent ua = UserAgent.parseUserAgentString(json.getString("userAgent"));
json.put("os", ua.getOperatingSystem());
json.put("browser", ua.getBrowser());
if(ua.getOperatingSystem().getName().equals("Unknown")){
String userAgent = json.getString("userAgent");
//没有发现是哪个浏览器,那可能是爬虫
for (int j = 0; j < spiderNameArray.length; j++) {
if(userAgent.indexOf(spiderNameArray[j]) > -1){
json.put("os", spiderExplainArray[j]);
}
}
if(json.get("os") == null){
if(userAgent.equals("Mozilla")){
//忽略
}else{
System.out.println("未发现的useragent : "+json.toString());
}
}
}
jsonArray.add(json);
}
vo.setList(jsonArray);
AliyunLog.addActionLog(getSiteId(), "获取最近7天内,最近的100条访问记录");
return vo;
}
示例15: spiderCount
import com.xnx3.DateUtil; //导入依赖的package包/类
/**
* 获取当前搜索引擎爬虫的爬取情况
*/
@RequestMapping("spiderCount")
@ResponseBody
public BaseVO spiderCount(HttpServletRequest request) throws LogException{
BaseVO vo = new BaseVO();
//当前10位时间戳
int currentTime = DateUtil.timeForUnix10();
//爬虫的具体访问统计
long[] spiderRequestCountArray = new long[spiderNameArray.length];
//最近7天的爬虫统计
for (int i = 0; i < spiderNameArray.length; i++) {
spiderRequestCountArray[i] = G.aliyunLogUtil.queryCount("siteid="+getSiteId()+" AND "+spiderNameArray[i], "", DateUtil.getDateZeroTime(currentTime - 604800), currentTime);
}
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < spiderNameArray.length; i++) {
if(spiderRequestCountArray[i] > 0){
JSONObject json = new JSONObject();
json.put("name", spiderExplainArray[i]);
json.put("value", spiderRequestCountArray[i]);
jsonArray.add(json);
}
}
vo.setInfo(jsonArray.toString());
AliyunLog.addActionLog(getSiteId(), "获取7天爬虫抓取记录");
return vo;
}