• 获取时间


    import java.util.Date;
    import java.text.SimpleDateFormat;

    public class NowString {
    public static void main(String[] args) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
    System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
    }
    }

    有时候要把String类型的时间转换为Date类型,通过以下的方式,就可以将你刚得到的时间字符串转换为Date类型了。

    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

    java.util.Date time=null;
    try {
       time= sdf.parse(sdf.format(new Date()));

    } catch (ParseException e) {

       e.printStackTrace();
    }

    当前月:int month = c.get(Calendar.MONTH)+1;

  • 相关阅读:
    Ridis学习笔记
    VMware虚拟机安装教程
    Spring中获取Bean的几种方式
    jQuery中的常用事件
    乱码解决
    自动装配
    通配符用法
    Spring
    Spring mvc简单案例
    jdbctemplate
  • 原文地址:https://www.cnblogs.com/LWMLWM/p/6863519.html
Copyright © 2020-2023  润新知