test.java

来自「事件提醒系统」· Java 代码 · 共 47 行

JAVA
47
字号
package com.myoa.cal.util;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test {
	
	public String StrToStrTime(String time){
		DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		DateFormat dateformat1 = new SimpleDateFormat("yyyy-M-d h:m:s");
		Date Udate = null;
		java.sql.Date Sdate = null;
		String date0 = null;
		try {
			Udate = dateformat1.parse(time);
			date0 = dateformat.format(Udate);
		}catch(Exception e){

		}
		return date0;		
	}
	
	
	public static void main(String[] args){
		DateUtil du = new DateUtil();
		Test tt = new Test();
		
//		Date d1 = du.StrToDate("2009-02-27 10:20:30");
//		Date d2 = du.StrToDate("2009-02-27 10:00:30");
//		long long1 = d1.getTime();
//		long space = 30 * 60 * 1000;
//		long result = long1 - space;
//		Date t_d = new Date(result);
//		
//		Timestamp ts2 = new Timestamp(d2.getTime());
//		Timestamp ts = new Timestamp(long1);
//		System.out.println(ts2.before(ts));
//		System.out.println(du.DateTimeToStr(t_d));
//		
		System.out.println(tt.StrToStrTime("2009-5-23 1:30:8"));
//		
	}

}

⌨️ 快捷键说明

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