sqldateconverter.java

来自「Struts2 + Spring JPA Hibernate demo.」· Java 代码 · 共 47 行

JAVA
47
字号
/*
 * $Id: SqlDateConverter.java 30 2006-06-08 13:26:40Z wjx $
 */
package com.vegeta.utils.datetime.converter;

import java.sql.Date;

import com.vegeta.utils.datetime.common.DateTimeStamp;
import com.vegeta.utils.datetime.common.JDateTime;
import com.vegeta.utils.datetime.common.JdtConverter;

/**
 * 
 * 
 * <p>
 * <a href="SqlDateConverter.java.html"><i>View Source</i></a>
 * </p>
 * 
 * @author wjx
 * @version $Revision: 30 $ $Date: 2006-06-08 21:26:40 +0800 (星期四, 08 六月 2006) $
 */
public class SqlDateConverter implements JdtConverter {

	public void load(JDateTime gt, Object o) {
		if (o instanceof Date) {
			Date d = (Date) o;
			gt.set(1900 + d.getYear(), d.getMonth() + 1, d.getDate());
		}
	}

	public Object get(JDateTime gt) {
		DateTimeStamp time = gt.getDateTimeStamp();
		return new Date(time.year - 1900, time.month - 1, time.day);
	}

	public void store(JDateTime gt, Object o) {
		if (o instanceof Date) {
			Date d = (Date) o;
			DateTimeStamp time = gt.getDateTimeStamp();
			d.setYear(time.year - 1900);
			d.setMonth(time.month - 1);
			d.setDate(time.day);
		}
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?