import java.io.File; import java.util.Calendar; import org.apache.struts2.ServletActionContext; private static final Logger logger = Logger.getLogger(PictureAction.class);
按年月创建文件夹:
Calendar cad = Calendar.getInstance(); String month=String.valueOf(cad.get(Calendar.MONTH) + 1); if(month.length()<2){ month=0+month; } //相对存放路径 String savePath = "/upload/picture/"+String.valueOf(cad.get(Calendar.YEAR))+ month; try { File dirFile = new File(ServletActionContext.getServletContext().getRealPath(savePath)); boolean bFile = dirFile.exists(); if (bFile == true) { //The folder exists. } else { //The folder do not exist,now trying to create a one. bFile = dirFile.mkdir(); if (bFile == true) { //Create successfully! } else { //Disable to make the folder,please check the disk is full or not. logger.error("[java]PictureAction create folder is error,because Disable to make the folder,please check the disk is full or not."); } } } catch (Exception err) { logger.error("[java]PictureAction create folder is error,because the disk is full or not.", err); }
相关推荐
用java来写个类,获取当前的年月日,自己也可以改,获取当前系统时间
LabVIEW小程序;按日期创建文件夹;txt文件,大神绕道!
java获取年月日时分秒的方法
java 获取年月日的代码,经测试有效。
Labview 的按时间建立文件夹和excel模板 可做参考 其他功能需要自己去建立。
【JAVA】获取年月日(格式:xxxx年xx月xx日)、获取最近一年的年月(格式:xxxx年xx月).docx
批处理一键创建1年12个月31日文件夹,并在日期里面创建多个文件夹
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class TestOutDate { public static void main(String[] args) { //method 1...
Java 根据用户指定的某年某月某日,判断这一天是一年中的第几天,具体思路是:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且输入月份大于3时需考虑多加一天。这是一个...
//获取日 int hour=cal.get(Calendar.HOUR);//小时 System.out.println(year); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date parse = simpleDateFormat.parse("2019-09-08")...
问题:输入年月日,输出那天是星期几? 回答:java代码实现的;主要是循环的利用,以及闰年与平年的判断。
java 日程管理记事本,可按年月日查询行程记录。也可进行修改操作
输入两个年月日,(1)判断两个日期是否相同,并且将相差的天数显示出来;(2)将日期后推或前推N天,并将该日期输出。
c语言实现文件夹以系统时间命名,非常方便数据的存储和再次调用~!
日期操作类 Long转日期 字符串毫秒转日期 格式化日期转换方法,年 月 日 时 分 秒 把格式化的日期补全 把格式化的日期转化为毫秒 获取当天凌晨,夜间整点时间毫秒 校验日期是否合法 得到n天之后的日期 得到n天之后是...
获取出生年月日工具类
年月日产量折线图 年月日产量折线图 年月日产量折线图 年月日产量折线图 年月日产量折线图 年月日产量折线图
用JavaScript实现了年月月下拉框三联动,分闰年平年二月的天数的。
java-core 实现fckeditor按日期创建目录上传图片
主要为大家详细介绍了Java获取当前时间年月日的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下