将字符串形式的日期转换成日期对象 var strTime="2011-04-16"; //字符串日期格式 var date= new Date(Date.parse(strTime.replace(/-/g, "/"))); //转换成Data(); var month=date.getMonth()+1; //获取当前月份 -----------------------------------------------------------
[From] http://bigdataprogrammers.com/string-date-conversion-hive/ Please refer below table to convert any date format into fixed format i.e yyyy-MM-dd . Input column name: dt (String).Replace dt with your column name. Input Format Code Output Format
//将字符串转换成java.util.date类型 DateFormat format = new SimpleDateFormat("yyyyMMDD"); Date date1 = format.parse(startDate); //将java.util.date类型转换成java.sql.date类型 skg.statStartTime = new java.sql.Date(date1.getTime()); skg.statEndTime = new java.sql.Da