• 时间和字符串的互转


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

    public class DateAndString {


        public String dateToString(Date date){
            String datetime = null;
            SimpleDateFormat timeFormat = null;
            timeFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
            datetime = timeFormat.format(date);
            return datetime;
        }


        public Date stringToDate(String time){
            Date date = null;
            SimpleDateFormat timeFormat = null;
            timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                date = timeFormat.parse(time);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return date;
        }


    }

  • 相关阅读:
    mongodb分片
    mongodb副本集搭建
    mongodb数据导入导出
    mongodb安装、配置
    redis副本集
    redis安装,第一天
    redis常用命令
    mac中安装 RabbitMQ
    Vue常用模块
    nodejs,koa2常用模块
  • 原文地址:https://www.cnblogs.com/Jiphen/p/2564154.html
Copyright © 2020-2023  润新知