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导入\导出工具类

    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. ZeroMQ接口函数之 :zmq_recv – 从一个socket上接收一个消息帧

    ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq_recv zmq_recv(3)        ØMQ Manual - ØMQ/4.1.0 Name zmq_r ...

  2. 如何解决Linux下通过root无法远程登录

    解决问题 1.确认ssh服务已安装,通过普通用户连接成功: 2.确认ssh配置是否对root进行特殊设置,修改/etc/ssh/sshd_config文件中 PermitRootLogin witho ...

  3. websocket 实现聊天功能

    <html> <head> <base href="<%=basePath%>"> <title>webscoket t ...

  4. hibernate_Restrictions用法

    方法   说明 Restrictions.eq = Restrictions.allEq 利用Map来进行多个等于的限制 Restrictions.gt > Restrictions.ge &g ...

  5. python与shell的3种交互方式介绍

    [目录] 1.os.system(cmd) 2.os.popen(cmd) 3.利用subprocess模块 4.subprocessor模块进阶 [概述] 考虑这样一个问题,有hello.py脚本, ...

  6. 从网页上抓取Windows补丁信息然后整型输出(Python)

    Powershell实现:http://www.cnblogs.com/IvanChen/p/4488246.html 今天通过Python实现: # coding=utf-8 import re i ...

  7. Java备份Oracle数据库

    Java备份Oracle数据库 Java线程.Process.ProcessBuilder 2010 年 6 月 20 日 文章内容描述了使用Java执行外部Oracle导出命令备份数据库功能的示例, ...

  8. [转载] Win7KB3146706补丁导致蓝屏0x0000006B的修复方案

    进入winpe,将附件的蓝屏6B修复补丁kb3146706.zip的补丁替换windows/system32下面的ci.dll文件,里面有64和32位系统的,替换了文件就可以进入系统了. 启动进入系统 ...

  9. JAVA继承与覆写

    实例:数组操作 首先是开发一个整型数组父类,要求从外部控制数组长度,并实现保存数据以及输出.然后子类中实现排序和反转. 基础父类代码如下: class Array { private int data ...

  10. JAVA枚举的作用与好处

    枚举是一种规范它规范了参数的形式,这样就可以不用考虑类型的不匹配并且显式的替代了int型参数可能带来的模糊概念 枚举像一个类,又像一个数组.Enum作为Sun全新引进的一个关键字,看起来很象是特殊的c ...