This commit is contained in:
wentch
2015-12-09 16:38:05 +08:00
parent 05c75f95b9
commit 84ebb4ccc3
5 changed files with 61 additions and 10 deletions

View File

@@ -10,7 +10,9 @@ import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 自动全量缓存
* 自动加载。 使用场景有两种:
* 一、 扫描时自动加载。 系统在启动时会扫描classpath下Service和Servlet的实现类默认情况下会加载所有的实现类 只有当标记为@AutoLoad(false)时才会被忽略。 没标记的与标记为@AutoLoad(true)是等价的。
* 二、 Entity类数据加载。 DataSource初始化某个标记为@javax.persistence.Cacheable的Entity类时如果该类存在@AutoLoad时则需要将Entity类对应的表数据全量加载进缓存中。
*
* @author zhangjx
*/

View File

@@ -9,6 +9,7 @@ import java.nio.*;
import java.nio.charset.*;
/**
* 简单的byte[]操作类。
*
* @author zhangjx
*/
@@ -134,12 +135,16 @@ public final class ByteArray {
public String toDecodeString(final int offset, int len, final Charset charset) {
int index = offset;
for (int i = offset; i < (offset + len); i++) {
if (content[i] == '+') {
content[index] = ' ';
} else if (content[i] == '%') {
content[index] = (byte) ((hexBit(content[++i]) * 16 + hexBit(content[++i])));
} else {
content[index] = content[i];
switch (content[i]) {
case '+':
content[index] = ' ';
break;
case '%':
content[index] = (byte) ((hexBit(content[++i]) * 16 + hexBit(content[++i])));
break;
default:
content[index] = content[i];
break;
}
index++;
}

View File

@@ -8,6 +8,7 @@ package org.redkale.util;
import java.util.*;
/**
* 便于操作的HashMap类
*
* @author zhangjx
*/

View File

@@ -8,6 +8,8 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
*
* 获取泛型的Type类
*
* @author zhangjx
* @param <T>

View File

@@ -19,6 +19,8 @@ import javax.net.ssl.*;
*/
public final class Utility {
private static final int zoneRawOffset = TimeZone.getDefault().getRawOffset();
private static final String format = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%tL";
private static final Charset UTF_8 = Charset.forName("UTF-8");
@@ -128,12 +130,41 @@ public final class Utility {
return back;
}
/**
* 获取当天凌晨零点的格林时间
*
* @return
*/
public static long midnight() {
return midnight(System.currentTimeMillis());
}
/**
* 获取指定时间当天凌晨零点的格林时间
*
* @param time
* @return
*/
public static long midnight(long time) {
return (time + zoneRawOffset) / 86400000 * 86400000 - zoneRawOffset;
}
/**
* 获取当天20151231格式的int值
*
* @return
*/
public static int today() {
java.time.LocalDate today = java.time.LocalDate.now();
return today.getYear() * 10000 + today.getMonthValue() * 100 + today.getDayOfMonth();
}
//时间点所在星期的周一
/**
* 获取时间点所在星期的周一
*
* @param time
* @return
*/
public static long monday(long time) {
ZoneId zid = ZoneId.systemDefault();
Instant instant = Instant.ofEpochMilli(time);
@@ -142,7 +173,12 @@ public final class Utility {
return ld.atStartOfDay(zid).toInstant().toEpochMilli();
}
//时间点所在星期的周日
/**
* 获取时间点所在星期的周日
*
* @param time
* @return
*/
public static long sunday(long time) {
ZoneId zid = ZoneId.systemDefault();
Instant instant = Instant.ofEpochMilli(time);
@@ -151,7 +187,12 @@ public final class Utility {
return ld.atStartOfDay(zid).toInstant().toEpochMilli();
}
//时间点所在月份的1号
/**
* 获取时间点所在月份的1号
*
* @param time
* @return
*/
public static long monthFirstDay(long time) {
ZoneId zid = ZoneId.systemDefault();
Instant instant = Instant.ofEpochMilli(time);