Java Code Examples for com.blade.kit.DateKit#toString()
The following examples show how to use
com.blade.kit.DateKit#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaleUtils.java From tale with MIT License | 5 votes |
public static String getFileKey(String name) { String prefix = "/upload/" + DateKit.toString(new Date(), "yyyy/MM"); String dir = UP_DIR + prefix; if (!Files.exists(Paths.get(dir))) { new File(dir).mkdirs(); } return prefix + "/" + com.blade.kit.UUID.UU32() + "." + StringKit.fileExt(name); }
Example 2
Source File: TaleUtils.java From tale with MIT License | 4 votes |
private static Url parse(Contents contents) { Url url = new Url(Commons.site_url() + "/article/" + contents.getCid()); url.lastmod = DateKit.toString(contents.getModified(), "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); return url; }
Example 3
Source File: SiteService.java From tale with MIT License | 4 votes |
/** * 系统备份 * * @param bkType * @param bkPath * @param fmt */ public BackResponse backup(String bkType, String bkPath, String fmt) throws Exception { BackResponse backResponse = new BackResponse(); if ("attach".equals(bkType)) { if (StringKit.isBlank(bkPath)) { throw new TipException("请输入备份文件存储路径"); } if (!Files.isDirectory(Paths.get(bkPath))) { throw new TipException("请输入一个存在的目录"); } String bkAttachDir = AttachController.CLASSPATH + "upload"; String bkThemesDir = AttachController.CLASSPATH + "templates/themes"; String fname = DateKit.toString(new Date(), fmt) + "_" + StringKit.rand(5) + ".zip"; String attachPath = bkPath + "/" + "attachs_" + fname; String themesPath = bkPath + "/" + "themes_" + fname; ZipUtils.zipFolder(bkAttachDir, attachPath); ZipUtils.zipFolder(bkThemesDir, themesPath); backResponse.setAttach_path(attachPath); backResponse.setTheme_path(themesPath); } // 备份数据库 if ("db".equals(bkType)) { String filePath = "upload/" + DateKit.toString(new Date(), "yyyyMMddHHmmss") + "_" + StringKit.rand(8) + ".db"; String cp = AttachController.CLASSPATH + filePath; Files.createDirectory(Paths.get(cp)); Files.copy(Paths.get(SqliteJdbc.DB_PATH), Paths.get(cp)); backResponse.setSql_path("/" + filePath); // 10秒后删除备份文件 new Timer().schedule(new TimerTask() { @Override public void run() { new File(cp).delete(); } }, 10 * 1000); } return backResponse; }