邓博泽 java最全的DateUtil工具类

时间:2022-05-23 22:03:03
package com.kld.yijie.web.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap; /**
* Created by shanks on 15/4/21.
*/
public class DateUtil {
private static Logger logger = LoggerFactory.getLogger(DateUtil.class);
private static String defaultDatePattern = "yyyy-MM-dd";
public static String secondDatePattern = "yyyy-MM-dd HH:mm:ss";
/**
* 格式:yyyy-MM-dd
*/
public static final int FMT_DATE_YYYY_MM_DD = 1; /**
* 格式:yyyyMMdd
*/
public static final int FMT_DATE_YYYYMMDD = 2; /**
* 格式:yyMMdd
*/
public static final int FMT_DATE_YYMMDD = 3; /**
* 格式:yyyy
*/
public static final int FMT_DATE_YYYY = 4; /**
* 格式:yyMM
*/
public static final int FMT_DATE_YYMM = 5; /**
* 格式:yyyyMM
*/
public static final int FMT_DATE_YYYYMM = 6; /**
* 格式:yyyy-MM-dd HH:mm:ss
*/
public static final int FMT_DATE_YYYYMMDDHHmmss = 7; /**
* 格式:yyyyMMddHHmmss
*/
public static final int FMT_DATE_YYYYMMDDHHmmss1 = 8; /**
* 格式:yyyy/MM/dd
*/
public static final int FMT_DATE_YYYYMMDD9 = 9; /**
* 格式:HH:mm:ss
*/
public static final int FMT_DATE_HHMMSS = 10; /**
* 格式:yyyy年MM月dd日
*/
public static final int FMT_DATE_YYYY_MM_DD_CN = 11; /**
* 格式:yyyy年MM月dd日 HH时mm分ss秒
*/
public static final int FMT_DATE_YYYYMMDDHHmmss_CN = 12; /**
* 格式:yyyy年MM月
*/
public static final int FMT_DATE_YYYY_MM_CN = 13; /**
* 格式:yyyy-MM-dd HH:mm
*/
public static final int FMT_DATE_YYYY_MM_DDHHMM = 14;
/**
* 获得默认的 date pattern
*/
public static String getDatePattern() {
return defaultDatePattern;
}
/**
* 使用参数Format格式化Date成字符串
*/
public static String format(Date date, String pattern) {
String returnValue = ""; if (date != null) {
SimpleDateFormat df = new SimpleDateFormat(pattern);
returnValue = df.format(date);
} return (returnValue);
}
/**
* 根椐时间和格式获得时间
*
* @return String
*/
public static String formatDate(Date date, int nFmt) {
if (date == null) {
return "";
}
SimpleDateFormat fmtDate = null;
switch (nFmt) {
default:
case DateUtil.FMT_DATE_YYYY_MM_DD:
fmtDate = new SimpleDateFormat("yyyy-MM-dd");
break;
case DateUtil.FMT_DATE_YYYYMMDD:
fmtDate = new SimpleDateFormat("yyyyMMdd");
break;
case DateUtil.FMT_DATE_YYMMDD:
fmtDate = new SimpleDateFormat("yyMMdd");
break;
case DateUtil.FMT_DATE_YYYY:
fmtDate = new SimpleDateFormat("yyyy");
break;
case DateUtil.FMT_DATE_YYMM:
fmtDate = new SimpleDateFormat("yyMM");
break;
case DateUtil.FMT_DATE_YYYYMM:
fmtDate = new SimpleDateFormat("yyyyMM");
break;
case DateUtil.FMT_DATE_YYYYMMDDHHmmss:
fmtDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
break;
case DateUtil.FMT_DATE_YYYYMMDDHHmmss1:
fmtDate = new SimpleDateFormat("yyyyMMddHHmmss");
break;
case DateUtil.FMT_DATE_YYYYMMDD9:
fmtDate = new SimpleDateFormat("yyyy/MM/dd");
break;
case DateUtil.FMT_DATE_HHMMSS:
fmtDate = new SimpleDateFormat("HH:mm:ss");
break;
case DateUtil.FMT_DATE_YYYY_MM_DD_CN:
fmtDate = new SimpleDateFormat("yyyy年MM月dd日");
break;
case DateUtil.FMT_DATE_YYYYMMDDHHmmss_CN:
fmtDate = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
break;
case DateUtil.FMT_DATE_YYYY_MM_CN:
fmtDate = new SimpleDateFormat("yyyy年MM月");
break;
case DateUtil.FMT_DATE_YYYY_MM_DDHHMM:
fmtDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:");
break;
}
return fmtDate.format(date);
}
/**
* 使用预设格式将字符串转为Date
*/
public static Date parse(String strDate) {
return parse(strDate, getDatePattern());
} /**
* 使用参数Format将字符串转为Date
*/
public static Date parse(String strDate, String pattern) {
SimpleDateFormat df = new SimpleDateFormat(pattern);
try {
return df.parse(strDate);
} catch (ParseException e) {
logger.error(e.getMessage());
return null;
}
}
/**
* 在日期上增加数个整月
*/
public static Date addMonth(Date date, int n) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, n);
return cal.getTime();
} /**
* 获得给定日期当前月份的第一天的日期
* @param date
* @return
*/
public static Date getFirstDayOfMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.getTime();
} /**
* 获得给定日期当前月份的最后一天的日期
* @param date
* @return
*/
public static Date getLastDayOfMonth(Date date) {
Date resultDate = getFirstDayOfMonth(addMonth(date, 1)); Calendar calendar = Calendar.getInstance();
calendar.setTime(resultDate); calendar.add(Calendar.DAY_OF_YEAR, -1); return calendar.getTime();
}
/**
* 得到系统当前的日期和时间 格式为YYYY-MM-DD hh:mm:ss
* @return
*/
public static final String getSystemCurrentDateTime() {
Calendar newCalendar = Calendar.getInstance();
newCalendar.setTimeInMillis(System.currentTimeMillis());
int year = newCalendar.get(Calendar.YEAR);
int month = newCalendar.get(Calendar.MONTH) + 1;
int day = newCalendar.get(Calendar.DAY_OF_MONTH);
int hour = newCalendar.get(Calendar.HOUR_OF_DAY);
int minute = newCalendar.get(Calendar.MINUTE);
int second = newCalendar.get(Calendar.SECOND);
return doTransform(year, month, day, hour, minute, second);
}
/**
* 返回格式为YYYY-MM-DD hh:mm:ss
*
* @param year-年
* @param month-月
* @param day-日
* @param hour-小时
* @param minute-分钟
* @param second-秒
* @return
*/
private static final String doTransform(int year, int month, int day, int hour, int minute, int second) {
StringBuffer result = new StringBuffer();
result.append(String.valueOf(year)).append("-").append(month < 10 ? "0" + String.valueOf(month) : String.valueOf(month)).append("-").append(day < 10 ? "0" + String.valueOf(day) : String.valueOf(day)).append(" ").append(hour < 10 ? "0" + String.valueOf(hour) : String.valueOf(hour)).append(
":").append(minute < 10 ? "0" + String.valueOf(minute) : String.valueOf(minute)).append(":").append(second < 10 ? "0" + String.valueOf(second) : String.valueOf(second));
return result.toString();
}
/**
* 根据转换格式,把Timestamp日期转换为字符串日期
* @param Timestamp
* @param nFmt
* @return
*/
public static String timestampToString(Timestamp Timestamp, int nFmt) {
if (Timestamp == null) {
return "";
}
java.util.Date d = new java.util.Date(Timestamp.getTime());
return formatDate(d, nFmt);
}
/**
* 根椐系统时间和格式获得时间
*
* @param nFmt
* @return
*/
public static String getSystemDate(int nFmt) {
Calendar calendar = Calendar.getInstance();
return formatDate(calendar.getTime(), nFmt);
}
/**
* 使用预设Format格式化Date成字符串
*/
public static String format(Date date) {
return format(date, getDatePattern());
}
/**
* 返回预设Format的当前日期字符串
*/
public static String getToday() {
Date today = new Date();
return format(today);
}
/**
* 返回量日期相差的天数
* date1:起始时间;date2截止时间;systemDate 系统当前时间
* @throws ParseException
* */
public static String getSubDays(String stratDate) throws ParseException{
long day;
Date strDate = new SimpleDateFormat("yyyy-MM-dd").parse(stratDate);
Date sysDate = new SimpleDateFormat("yyyy-MM-dd").parse(getSystemDate(1));
day=(strDate.getTime()-sysDate.getTime())/(24*60*60*1000);
return String.valueOf(day);
}
/**
* ORA标准时间格式
*/
private static final SimpleDateFormat ORA_DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMddHHmm"); /**
* 带时分秒的ORA标准时间格式
*
*/
private static final SimpleDateFormat ORA_DATE_TIME_EXTENDED_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); /**
* 创建一个标准ORA时间格式的克隆
*
* @return 标准ORA时间格式的克隆
*/
@SuppressWarnings("unused")
private static synchronized DateFormat getOraDateTimeFormat() {
SimpleDateFormat theDateTimeFormat = (SimpleDateFormat) ORA_DATE_TIME_FORMAT.clone();
theDateTimeFormat.setLenient(false);
return theDateTimeFormat;
}
/**
* 创建一个带分秒的ORA时间格式的克隆
*
* @return 标准ORA时间格式的克隆
*/
private static synchronized DateFormat getOraExtendDateTimeFormat() {
SimpleDateFormat theDateTimeFormat = (SimpleDateFormat) ORA_DATE_TIME_EXTENDED_FORMAT.clone();
theDateTimeFormat.setLenient(false);
return theDateTimeFormat;
}
/**
* 返回格式为YYYY-MM-DD hh:mm:ss
*
* @param date-输入格式为ORA标准时间格式
* @return
*/
private static String doTransform(String date) {
StringBuffer buffer = new StringBuffer();
buffer.append(date.substring(0, 4));
buffer.append("-");
buffer.append(date.substring(4, 6));
buffer.append("-");
buffer.append(date.substring(6, 8));
buffer.append(" ");
buffer.append(date.substring(8, 10));
buffer.append(":");
buffer.append(date.substring(10, 12));
buffer.append(":");
buffer.append(date.substring(12, 14)); return buffer.toString();
}
/**
* 将输入格式为2004-8-13 12:31:22类型的字符串转换为标准的Date类型
*
* @param dateStr
* @return
*/
public static synchronized Date toDate(String dateStr) {
String[] list0 = dateStr.split(" ");
String date = list0[0];
String time = list0[1];
String[] list1 = date.split("-");
int year = new Integer(list1[0]).intValue();
int month = new Integer(list1[1]).intValue();
int day = new Integer(list1[2]).intValue();
String[] list2 = time.split(":");
int hour = new Integer(list2[0]).intValue();
int min = new Integer(list2[1]).intValue();
int second = new Integer(list2[2]).intValue();
Calendar cale = Calendar.getInstance();
cale.set(year, month - 1, day, hour, min, second);
return cale.getTime();
}
public static String dateToStringFirst(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date); String dateToStr = c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1) + "-" + "01" + " 00:00:00";
return dateToStr;
} public static String dateToStringLast(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
String dateToStr = c.get(Calendar.YEAR) + "-" + (c.get(Calendar.MONTH) + 1) + "-" + c.getActualMaximum(Calendar.DAY_OF_MONTH) + " 23:59:59";
return dateToStr;
}
/*
*获取当天是本年第几周
*/
public static int getCurrentWeek(){ Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(new Date());
return calendar.get(Calendar.WEEK_OF_YEAR)-2;
} public static int getStartDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);
date = calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
return Integer.parseInt(df.format(date)); } public static int getendDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, -1);
date = calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
return Integer.parseInt(df.format(date)); }
//获取当前日期的字符串表达式
public static String getCurrentDate(){
Calendar calendar = Calendar.getInstance();
Date date=calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyMMdd");
String sdate=df.format(date);
return sdate;
}
//获取当前日期的字符串表达式
public static String getCurrentDateFormat(String format){
Calendar calendar = Calendar.getInstance();
Date date=calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat(format);
String sdate=df.format(date);
return sdate;
}
public static String getCurrentDate2(){
Calendar calendar = Calendar.getInstance();
Date date=calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
String sdate=df.format(date);
return sdate;
}
//获取当前日期的字符串表达式
public static Date getDate(){
Calendar calendar = Calendar.getInstance();
Date date=calendar.getTime();
return date;
}
//指定日期格式与日期参数,格式化日期
public static Date formatDate(String format,Date date){
SimpleDateFormat df = new SimpleDateFormat(format);
String d=df.format(date);
try {
date = df.parse(d);
} catch (ParseException e) { e.printStackTrace();
}
return date;
}
//指定日期格式参数,给定字符串的日期参数,转换成该格式的日期
public static Date toDate(String format,String time){
SimpleDateFormat df = new SimpleDateFormat(format);
System.out.println(format);
Date date=null; if(time==null||"".equals(time)){
return null;
}
try {
date = df.parse(time);
} catch (ParseException e) { e.printStackTrace();
}
return date;
}
//根据指定时间与时间分量、时间分量值计算日期
public static Date countDate(String unit,int value,Date date){
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
if("year".equals(unit)){
calendar.set(calendar.YEAR, calendar.get(calendar.YEAR)+value);
}else if("month".equals(unit)){
calendar.set(calendar.MONTH,calendar.get(calendar.MONTH)+value);
}else if("day".equals(unit)){
calendar.set(calendar.DAY_OF_MONTH,calendar.get(calendar.DAY_OF_MONTH)+value);
}else if("hour".equals(unit)){
calendar.set(calendar.HOUR_OF_DAY,value);
}else if("minute".equals(unit)){
calendar.set(calendar.MINUTE,calendar.get(calendar.MINUTE)+value);
}else if("second".equals(unit)){
calendar.set(calendar.SECOND,value);
}
return calendar.getTime();
}
//根据指定时间与时间分量、时间分量值计算日期
public static Date operDate(String operObj, Integer operNum, Date operDate) {
Date date = null;
try {
Calendar calendar = Calendar.getInstance();
if (operDate != null) {
calendar.setTime(operDate);
} else {
calendar.setTime(new Date());
}
if (operObj.equals("year")) {
int year = calendar.get(Calendar.YEAR);
calendar.set(Calendar.YEAR, year + operNum.intValue()); } else if (operObj.equals("month")) {
int month = calendar.get(Calendar.MONTH);
calendar.set(Calendar.MONTH, month + operNum.intValue());
} else if (operObj.equals("day")) {
int day = calendar.get(Calendar.DAY_OF_YEAR);
calendar.set(Calendar.DAY_OF_YEAR, day + operNum.intValue());
} else if (operObj.equals("hour")) {
int hour = calendar.get(Calendar.HOUR_OF_DAY);
calendar.set(Calendar.HOUR_OF_DAY, hour + operNum.intValue());
} else if (operObj.equals("minute")) {
int hour = calendar.get(Calendar.MINUTE);
calendar.set(Calendar.MINUTE, hour + operNum.intValue());
}
date = calendar.getTime();
} catch (Exception e) { }
return date;
}
//根据时间分量计算以后时间
public static Date countDate(String unit,Date date){
if(unit.equals("年卡")){
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.YEAR, calendar.get(calendar.YEAR)+1);
System.out.println("执行了年卡");
return calendar.getTime();
}else if(unit.equals("季卡")){
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.MONTH, calendar.get(calendar.MONTH)+3);
System.out.println("执行了季卡");
return calendar.getTime();
}else{
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.MONTH, calendar.get(calendar.MONTH)+1);
System.out.println("执行了月卡");
return calendar.getTime();
}
}
//对日期天数的计算
public static Date countDay(int day,Date date){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(calendar.DAY_OF_MONTH, calendar.get(calendar.DAY_OF_MONTH) + day);
return calendar.getTime();
}
//根据当前时间计算当前的月份
public static int getCurrentMoth(){
Calendar calendar =Calendar.getInstance();
return calendar.get(calendar.MONTH)+1;
}
//根据指定时间计算指定时间的月份
public static int getMonthByDate(Date date){
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
return calendar.get(calendar.MONTH)+1;
}
//根据月份返回对应的中文,比如1返回一月
public static String getChineseMonth(int num){
switch (num){
case 1:return "一月";
case 2:return "二月";
case 3:return "三月";
case 4:return "四月";
case 5:return "五月";
case 6:return "六月";
case 7:return "七月";
case 8:return "八月";
case 9:return "九月";
case 10:return "十月";
case 11:return "十一月";
default :return "十二月";
}
}
//根据参数计算日期
public static Date countDateByParam(int num){
Calendar calendar =Calendar.getInstance();
calendar.add(Calendar.MONTH,num);
//calendar.set(Calendar.MONTH.MONTH,num);
Date date=calendar.getTime();
System.out.println(toString(date,"yyyy-MM-dd HH:mm:ss"));
return calendar.getTime();
}
//计算指定日期的月份的第一天
public static Date countDateFirstDay(Date date){
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
final int firstDay=calendar.getActualMinimum(calendar.DAY_OF_MONTH);
Date firstDate=calendar.getTime();
firstDate.setDate(firstDay);
return firstDate;
}
//计算指定日期的月份的最后一天
public static Date countDateLastDay(Date date){
Calendar calendar =Calendar.getInstance();
calendar.setTime(date);
final int lastDay=calendar.getActualMaximum(calendar.DAY_OF_MONTH);
Date lastDate=calendar.getTime();
lastDate.setDate(lastDay);
return lastDate;
}
//根据月份计算当前是第几季度
public static int getCurrentQuarter(int month){
int quarter;
if(month%3==0){
quarter=month/3;
}else{
quarter=month/3+1;
}
return quarter;
}
//根据月份与消费需求类型(季2、月3、周4)计算日期范围
public static HashMap<String,Date> getStartAndEndTime(int consumeType){
int month= DateUtil.getCurrentMoth();
Calendar calendar =Calendar.getInstance();
//calendar.setTime(new Date());
HashMap<String,Date> time=new HashMap<String,Date>();
Date startTime;
Date endTime;
if(consumeType==2){
int quarter=getCurrentQuarter(month);
if(quarter==1){
startTime=calendar.getTime();
calendar.set(calendar.get(Calendar.YEAR),0,1);
calendar.set(calendar.MONTH,2);
int lastDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(calendar.get(Calendar.YEAR),2,lastDay);
endTime=calendar.getTime();
time.put("startTime",startTime);
time.put("endTime",endTime);
}else if(quarter==2){
calendar.set(calendar.get(Calendar.YEAR),3,1);
startTime=calendar.getTime();
calendar.set(calendar.MONTH,5);
int lastDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(calendar.get(Calendar.YEAR),5,lastDay);
endTime=calendar.getTime();
time.put("startTime", startTime);
time.put("endTime",endTime);
}else if(quarter==3){
calendar.set(calendar.get(Calendar.YEAR),6,1);
startTime=calendar.getTime();
calendar.set(calendar.MONTH,8);
int lastDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(calendar.get(Calendar.YEAR),8,lastDay);
endTime=calendar.getTime();
time.put("startTime", startTime);
time.put("endTime",endTime);
}else if(quarter==4){
calendar.set(calendar.get(Calendar.YEAR),9,1);
startTime=calendar.getTime();
calendar.set(calendar.MONTH,11);
int lastDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(calendar.get(Calendar.YEAR),11,lastDay);
endTime=calendar.getTime();
time.put("startTime", startTime);
time.put("endTime",endTime);
}
}else if(consumeType==3){
calendar.set(calendar.get(Calendar.YEAR),month-1,1);
startTime=calendar.getTime();
int lastDay=calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(calendar.get(Calendar.YEAR),month-1,lastDay);
endTime=calendar.getTime();
time.put("startTime", startTime);
time.put("endTime",endTime);
}else if(consumeType==4){
int week=calendar.get(Calendar.DAY_OF_WEEK)-1;
System.out.println("week:"+week);
calendar.add(Calendar.DAY_OF_MONTH, -week+1);
startTime=calendar.getTime();
Calendar c=Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, 7-week);
endTime=c.getTime();
time.put("startTime", startTime);
time.put("endTime",endTime);
}
return time;
} public static String toString(Date date, String formatString){
if(null == date)return null;
SimpleDateFormat df = new SimpleDateFormat(formatString);
return df.format(date);
}
}

邓博泽 java最全的DateUtil工具类的更多相关文章

  1. Java操作文件夹的工具类

    Java操作文件夹的工具类 import java.io.File; public class DeleteDirectory { /** * 删除单个文件 * @param fileName 要删除 ...

  2. Java汉字转成汉语拼音工具类

    Java汉字转成汉语拼音工具类,需要用到pinyin4j.jar包. import net.sourceforge.pinyin4j.PinyinHelper; import net.sourcefo ...

  3. java中excel导入&bsol;导出工具类

    1.导入工具 package com.linrain.jcs.test; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; import ...

  4. java中定义一个CloneUtil 工具类

    其实所有的java对象都可以具备克隆能力,只是因为在基础类Object中被设定成了一个保留方法(protected),要想真正拥有克隆的能力, 就需要实现Cloneable接口,重写clone方法.通 ...

  5. java代码行数统计工具类

    package com.syl.demo.test; import java.io.*; /** * java代码行数统计工具类 * Created by 孙义朗 on 2017/11/17 0017 ...

  6. Java加载Properties配置文件工具类

    Java加载Properties配置文件工具类 import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; ...

  7. Java 操作Redis封装RedisTemplate工具类

    package com.example.redisdistlock.util; import org.springframework.beans.factory.annotation.Autowire ...

  8. java后台表单验证工具类

    /** * 描述 java后台表单验证工具类 * * @ClassName ValidationUtil * @Author wzf * @DATE 2018/10/27 15:21 * @VerSi ...

  9. 【转】Java压缩和解压文件工具类ZipUtil

    特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...

随机推荐

  1. PHP 高级编程&lpar;2&sol;5&rpar; - 反射API

    PHP 5 具有完整的反射 API,添加了对类.接口.函数.方法和扩展进行反向工程的能力. 此外,反射 API 提供了方法来取出函数.类和方法中的文档注释.通过使用反射API可以分析其他的类.接口.方 ...

  2. 从高处理解android与服务器交互(看懂了做开发就会非常的容易)

    今天帮一个朋友改一个bug 他可以算是初学者吧 .我给他看了看代码,从代码和跟他聊天能明显的发现他对客户端与服务器交互 基本 不是很了解.所以我花了更多时间去给他讲客户端与服务器的关系.我觉得从这个高 ...

  3. &sol;etc&sol;fstab一些信息

    [root@shine shine]# vim /etc/fstab ## /etc/fstab# Created by anaconda on Thu May 9 13:29:35 2013## A ...

  4. jquery validate form 异步提交

    jQuery取得select选中的值 jQuery("#select1  option:selected").text(); 相信很多人都用过jquery validate插件,非 ...

  5. 微信小程序计算金额长度异常解决办法

    今天在做微信小程序,在测试的时候偶然出现了一些问题,如下图. 心中的一阵不爽猛然袭来,完全是搞事情哈! 然后经过一番探索,用toFixed方法搞定了,此方法是对值进行四舍五入的. 解决后点了一大堆控制 ...

  6. 在服务器中使用 Entity Framework 的 Migration 更新数据库

    在开发环境中,每次我们对要对数据库进行更改,比如增加修改表字段等.改好Entity类后,我们只需在Nuget程序包管理控制台运行 update-database 脚本却可: update-databa ...

  7. MFC常用函数总结

    1.MFC编辑框.静态文本框相关的常用函数 <1>GetDlgItemText(ID ,str) 作用:从对话框中获取文本 第一个参数为要获取的编辑框(或者静态文本框.单选按钮等可以显示内 ...

  8. 怎样实现广度优先遍历(BFS)

    BFS过程: 一:訪问顶点V,并标记V为已经訪问 二:顶点V入队列 三:假设队列非空.进行运行,否则算法结束 四:出队列取得对头顶点u,假设顶点未被訪问,就訪问该顶点,并标记该顶点为已经訪问 五:查找 ...

  9. 如何创建效率高sql-建立索引

      我们做开发的人员,虽说自己不是专业从事数据库方面研究的(如DBA),但很多时候,公司没有专门的DBA,所以拿到具体的项目中,整体的数据库设计都是开发人员自己写的,随着时间的推移,加上开发经验的增长 ...

  10. java之打印机服务通俗做法

    javax.print包是API的主包,其中包含的类和接口能够让你:1)发现打印服务(Print Services)2)指定打印数据的格式 3)从一个打印服务创建打印工作(print jobs) 4) ...