zoukankan      html  css  js  c++  java
  • 时间和字符串的互转

    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;
        }


    }

  • 相关阅读:
    枚举
    枚举
    比特币中的密码学原理
    贪心
    dp
    二分
    mac解决matplotlib中文乱码
    Keras使用多个GPU并行
    pyspark使用-dataframe操作
    箱线图
  • 原文地址:https://www.cnblogs.com/Jiphen/p/2564154.html
Copyright © 2011-2022 走看看