今天在做项目过程中,查询一个表中数据时总碰到这个问题: java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date 查看数据库,发现某一字段为date类型,字段值为'0000-00-00' ;查看代码,我用的是rs.getString("字段名");于是把代码改成getDate("字段名");问题依旧! 查找资料发现:在数据库连接url后面加上ze
错误的写法: SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //这里的格式也可以是别的 createAt =format.parse(y.getCreatedAt()); //此处是接收到的 2019-09-27T18:31:31+08:00 正确的写法: SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH
function getLocalTime(nS) { var date = new Date(nS); Y = date.getFullYear() + '年'; M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '月'; D = date.getDate() + '日 '; h = date.getHours() + ':'; m = date.g
实体类 public class Test { [JsonIgnore] public string GetDate { get { return GetTime.ToString("yyyy-MM-dd"); } } [JsonProperty(PropertyName = "get")] [JsonConverter(typeof(UnixDateTimeConverter))] public DateTime GetTime { get; set; } [Js
1.时间戳转换为date long sjc=1442633777; SimpleDateFormat t = new SimpleDateFormat("yyyyMMddHHmmss"); String date = t.format(new Date(sjc*1000)); System.out.println(date); 2.date转换为时间戳 SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyyM