mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method and fix GlobalMailAccount
This commit is contained in:
@@ -214,9 +214,14 @@ public class DateUtil extends CalendarUtil {
|
||||
|
||||
/**
|
||||
* 获得指定日期是所在年份的第几周<br>
|
||||
* 此方法返回值与一周的第一天有关,比如:<br>
|
||||
* 2016年1月3日为周日,如果一周的第一天为周日,那这天是第二周(返回2)<br>
|
||||
* 如果一周的第一天为周一,那这天是第一周(返回1)<br>
|
||||
* 跨年的那个星期得到的结果总是1
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 周
|
||||
* @see DateTime#setFirstDayOfWeek(Week)
|
||||
*/
|
||||
public static int weekOfYear(Date date) {
|
||||
return DateTime.of(date).weekOfYear();
|
||||
|
@@ -421,6 +421,18 @@ public class IoUtil {
|
||||
|
||||
// -------------------------------------------------------------------------------------- read start
|
||||
|
||||
/**
|
||||
* 从流中读取UTF8编码的内容
|
||||
*
|
||||
* @param in 输入流
|
||||
* @return 内容
|
||||
* @throws IORuntimeException IO异常
|
||||
* @since 5.4.4
|
||||
*/
|
||||
public static String readUtf8(InputStream in) throws IORuntimeException {
|
||||
return read(in, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从流中读取内容
|
||||
*
|
||||
@@ -1251,7 +1263,7 @@ public class IoUtil {
|
||||
* @throws IORuntimeException IO异常
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public static long checksumValue(InputStream in, Checksum checksum){
|
||||
public static long checksumValue(InputStream in, Checksum checksum) {
|
||||
return checksum(in, checksum).getValue();
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@ import cn.hutool.core.text.replacer.ReplacerChain;
|
||||
|
||||
/**
|
||||
* HTML4的ESCAPE
|
||||
* 参考:Commons Lang3
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
|
@@ -160,9 +160,10 @@ public class PageUtil {
|
||||
* @return 分页条
|
||||
*/
|
||||
public static int[] rainbow(int pageNo, int totalPage, int displayCount) {
|
||||
boolean isEven = displayCount % 2 == 0;
|
||||
int left = displayCount / 2;
|
||||
int right = displayCount / 2;
|
||||
// displayCount % 2
|
||||
boolean isEven = (displayCount & 1) == 0;
|
||||
int left = displayCount >> 1;
|
||||
int right = displayCount >> 1;
|
||||
|
||||
int length = displayCount;
|
||||
if (isEven) {
|
||||
|
@@ -37,4 +37,11 @@ public class EscapeUtilTest {
|
||||
String unescape = EscapeUtil.unescape(escape);
|
||||
Assert.assertEquals(str, unescape);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeSinleQuotesTest(){
|
||||
String str = "'some text with single quotes'";
|
||||
final String s = EscapeUtil.escapeHtml4(str);
|
||||
Assert.assertEquals(str, s);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user