2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > excel java_java 读取 excel 或 excel

excel java_java 读取 excel 或 excel

时间:2021-05-15 22:42:47

相关推荐

excel java_java  读取 excel  或 excel

#re: java 读取 excel 或 excel

-10-15 22:44

惠万鹏

public class DateUtil

{

/**

*

*

Description:[得到当前的时间]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @return

*/

public static Date getDate()

{

Calendar canlendar = Calendar.getInstance();

return canlendar.getTime();

}

/**

*

*

Description:[提到指定的millis得到时间]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param millis

* @return

*/

public static Date getDate(long millis)

{

Calendar canlendar = Calendar.getInstance();

canlendar.clear();

canlendar.setTimeInMillis(millis);

return canlendar.getTime();

}

public static long getMillis()

{

return Calendar.getInstance().getTimeInMillis();

}

/**

*

*

Description:[得到指定日期的字符串(yyyy-MM-dd HH:mm:ss.SSS)]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param date

* @param formate

* @return

*/

public static String getDateFormate(Date date, String formate)

{

try

{

SimpleDateFormat simpleDateFormate = new SimpleDateFormat(formate);

return simpleDateFormate.format(date);

}

catch (Exception e)

{}

return "";

}

/**

*

*

Description:[根据日期得到YYYY-MM-DD HH:MM:SS.SSS格式字符串]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param date

* @return

*/

public static String get4yMdHmsS(Date date)

{

return DateUtil.getDateFormate(date, "yyyy-MM-dd HH:mm:ss.SSS");

}

/**

*

*

Description:[根据日期得到YYYY-MM-DD HH:MM:SS格式字符串]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param date

* @return

*/

public static String get4yMdHms(Date date)

{

return DateUtil.getDateFormate(date, "yyyy-MM-dd HH:mm:ss");

}

/**

*

*

Description:[根据日期得到YYYY-MM-DD HH:MM格式字符串]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param date

* @return

*/

public static String get4yMdHm(Date date)

{

return DateUtil.getDateFormate(date, "yyyy-MM-dd HH:mm");

}

/**

*

*

Description:[根据日期得到YYYY-MM-DD格式字符串]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param date

* @return

*/

public static String get4yMd(Date date)

{

return DateUtil.getDateFormate(date, "yyyy-MM-dd");

}

/**

*

*

Description:[把指定字符(yyyy-MM-dd HH:mm:ss.SSS)串转成Date]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param sDate

* @return

*/

public static Date parse4yMdHmsS(String sDate)

{

return DateUtil.parseDate(sDate, "yyyy-MM-dd HH:mm:ss.SSS");

}

/**

*

*

Description:[把指定字符(yyyy-MM-dd HH:mm:ss)串转成Date]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param sDate

* @return

*/

public static Date parse4yMdHms(String sDate)

{

return DateUtil.parseDate(sDate, "yyyy-MM-dd HH:mm:ss");

}

/**

*

*

Description:[把指定字符(yyyy-MM-dd HH:mm)串转成Date]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param sDate

* @return

*/

public static Date parse4yMdHm(String sDate)

{

return DateUtil.parseDate(sDate, "yyyy-MM-dd HH:mm");

}

/**

*

*

Description:[把指定字符(yyyy-MM-dd)串转成Date]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param sDate

* @return

*/

public static Date parse4yMd(String sDate)

{

return DateUtil.parseDate(sDate, "yyyy-MM-dd");

}

/**

*

*

Description:[根据指定格式,把字符串转成日期]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param sDate

* @param formate

* @return

*/

public static Date parseDate(String sDate, String formate)

{

SimpleDateFormat simpleDateFormate = new SimpleDateFormat(formate);

try

{

return simpleDateFormate.parse(sDate);

}

catch (ParseException e)

{

return null;

}

}

/**

*

*

Description:[两个长整型的时间相差(时间的毫秒数),可以得到指定的毫秒数,秒数,分钟数,天数]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param minuendTime[被减去的时间]

* @param subtrahendTime[减去的时间]

* @param tdatestr[part可选值["D","H","M","S","MS"]

* @return[minuendTime-subtrahendTime]

* @return

*/

public static double getDifTwoTime(Date minuendTime, Date subtrahendTime,

String tdatestr)

{

if (minuendTime == null || subtrahendTime != null)

{

return DateUtil.getDifTwoTime(minuendTime.getTime(), subtrahendTime

.getTime(), tdatestr);

}

return 0;

}

/**

*

*

Description:[两个长整型的时间相差(时间的毫秒数),可以得到指定的毫秒数,秒数,分钟数,天数]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param minuendTime[被减去的时间]

* @param subtrahendTime[减去的时间]

* @param tdatestr[part可选值["D","H","M","S","MS"]

* @return[minuendTime-subtrahendTime]

*/

public static double getDifTwoTime(long minuendTime, long subtrahendTime,

String tdatestr)

{

if (tdatestr == null || tdatestr.equals(""))

{

tdatestr = "MS";

}

double temp = 1;

/** 毫秒数 */

if ("MS".equalsIgnoreCase(tdatestr))

{

temp = 1;

}

/** 得到秒 */

if ("S".equalsIgnoreCase(tdatestr))

{

temp = 1000;

}

/** 得到分 */

if ("M".equalsIgnoreCase(tdatestr))

{

temp = 1000 * 60;

}

/** 得到小时 */

if ("H".equalsIgnoreCase(tdatestr))

{

temp = 1000 * 60 * 60;

}

/** 得到天 */

if ("D".equalsIgnoreCase(tdatestr))

{

temp = 1000 * 60 * 60 * 24;

}

return (minuendTime - subtrahendTime) / temp;

}

/**

*

*

Description:[从日期中得到指定部分(YYYY/MM/DD/HH/SS/SSS)数字]

*

Created by [Huyvanpull] [Oct 26, ]

*

Midified by [modifier] [modified time]

*

*

* @param date

* @param part[part可选值["Y","M","D","H","M","S","MS"]

* @return

*/

public static int getPartOfTime(Date date, String part)

{

Calendar canlendar = Calendar.getInstance();

canlendar.clear();

canlendar.setTime(date);

/** 得到年 */

if (part.equalsIgnoreCase("Y"))

{

return canlendar.get(Calendar.YEAR);

}

/** 得到月 */

if (part.equalsIgnoreCase("M"))

{

return canlendar.get(Calendar.MONTH) + 1;

}

/** 得到日 */

if (part.equalsIgnoreCase("D"))

{

return canlendar.get(Calendar.DAY_OF_MONTH);

}

/** 得到时 */

if (part.equalsIgnoreCase("H"))

{

return canlendar.get(Calendar.HOUR_OF_DAY);

}

/** 得到分 */

if (part.equalsIgnoreCase("M"))

{

return canlendar.get(Calendar.MINUTE);

}

/** 得到秒 */

if (part.equalsIgnoreCase("S"))

{

return canlendar.get(Calendar.SECOND);

}

/** 得到毫秒 */

if (part.equalsIgnoreCase("MS"))

{

return canlendar.get(Calendar.MILLISECOND);

}

return -1;

}

}回复更多评论

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。