📄 disposedate.java
字号:
package agenda;
/**
* 类名:DisposeDate
* 功能:时间形式转换与时间合法性判断
* 作者:孟欣(05376053)
* 开发环境:Eclipse 3.2、JDK 1.5.0
* 版本号:3.0
* 日期: 2008/4/9
*
*/
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DisposeDate {
/**
* 将字符串型时间转换成给定形式的时间
* @param strDate
* @return
*/
static public Date StoD(String strDate){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm");
Date valueDate = new Date();
try {
valueDate = sdf.parse(strDate);
} catch (ParseException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return valueDate;
}
/**
* 将给定形式的时间转换成字符口串形式,方便输出;
* @param Ddate
* @return
*/
static public String DtoS(Date Ddate){
String strDate = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH:mm");
strDate = sdf.format(Ddate);
return strDate;
}
/**
* 判断输入的会议开始时间是否早于结束时间
* @param startD
* @param endD
* @return
*/
static public boolean checkSeq(String startD, String endD){
long startVal = StoD(startD).getTime();
long endVal = StoD(endD).getTime();
if(startVal >= endVal){
// System.out.println("The start time can't be earler than the end time...\n");
return false;
}
return true;
}
/**
* 判断新插入的会议时间是否与已有的会议时间况突
* @param startD
* @param endD
* @param checkSD
* @param checkED
* @return
*/
static public boolean checkClash(String strStart, String strEnd, String checkStart, String checkEnd)
{
// Date startD = StoD(strStart);
// Date endD = StoD(strEnd);
//Date checkSD = StoD(checkStart);
// Date checkED = StoD(checkEnd);
long startVal = StoD(strStart).getTime();
long endVal = StoD(strEnd).getTime();
long checkSVal = StoD(checkStart).getTime();
long checkEVal = StoD(checkEnd).getTime();
if((checkSVal>=endVal)||(checkEVal<=startVal)) return true;
else{
// System.out.println("The time of the meeting clishs with the old one...\n");
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -