Tag: Date预览模式: 普通 | 列表
08-06
20

format String to Date

jdk中已经不再推荐用Date.parse(String arg);这样的直接的转换,取而代之的是:
                     String birthdayS = request.getParameter("birthday");
            DateFormat f=new SimpleDateFormat("yyyy-MM-dd");
            try {
                birthday=f.parse(birthdayS);
            } catch (ParseException e) {
                e.printStackTrace();
                log.error("When format birthday from String to Date  is error");
            }

查看更多...

Tags: format String Date

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 568
08-06
19

java date format

import java.util.Date;
import java.text.DateFormat;


/**
* 格式化时间类
* DateFormat.FULL = 0
* DateFormat.DEFAULT = 2
* DateFormat.LONG = 1

查看更多...

Tags: java Date format

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1087
08-06
18

Error performing load command

could not read column value from result set :某某字段(birthday)

出现了这样的错误,反复对照,映射文件没问题,字段没问题。

问题在哪呢?测试了下,如果birthday是String 类型的,没问题。如果是Date类型的。出错,其实原因很简单了,把记录中birthday字段的默认值0000 00-00-00改为正常即可

Tags: performing Date

分类:Database | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 848
07-12
11

Date To String,String To Date

Locale locale = Locale.US;
   Date now=new Date();
   SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss",locale);
   String showTime=f.format(now);
  
  
  //String   s="2007-12-10 03:30:08 ";  
  //java.text.DateFormat   f1=new   java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss",locale);  
  //java.util.Date   showTime=f.parse(s);

查看更多...

Tags: Date String 时间转换

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1256