1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package com.kingdee.shr.customer.gtiit.osf.util;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import com.kingdee.bos.BOSException;
- public class DateUtils {
-
- /**
- * 转换起始时间为00:00:00,结束时间为23:59:59
- * @param dateStr
- * @param isStart
- * @return
- * @throws BOSException
- */
- public static String formatDate(String dateStr,boolean isStart) throws BOSException{
- String formattedDate="";
- try{
- Date nowDate = new Date();
-
- if(!dateStr.contains(":")) {
- DateFormat df = new SimpleDateFormat("hh:mm:ss");
- dateStr=dateStr+" "+df.format(nowDate);
- }
- SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = inputFormat.parse(dateStr);
- SimpleDateFormat outputFormat=null;
- if(isStart){
- outputFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
- }else {
- outputFormat = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
- }
- formattedDate = outputFormat.format(date);
-
- }catch (Exception e){
- throw new BOSException(e);
- }
- return formattedDate;
- }
- }
|