mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add methods
This commit is contained in:
parent
8e8518c8d1
commit
81694dadfe
@ -13,6 +13,7 @@
|
|||||||
* 【db 】 增加Ignite数据库驱动识别
|
* 【db 】 增加Ignite数据库驱动识别
|
||||||
* 【core 】 DateUtil.parse支持带毫秒的UTC时间
|
* 【core 】 DateUtil.parse支持带毫秒的UTC时间
|
||||||
* 【core 】 IdcardUtil.Idcard增加toString(pr#1487@Github)
|
* 【core 】 IdcardUtil.Idcard增加toString(pr#1487@Github)
|
||||||
|
* 【core 】 ChineseDate增加getGregorianXXX方法(issue#1481@Github)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【core 】 修复IoUtil.readBytes的FileInputStream中isClose参数失效问题(issue#I3B7UD@Gitee)
|
* 【core 】 修复IoUtil.readBytes的FileInputStream中isClose参数失效问题(issue#I3B7UD@Gitee)
|
||||||
|
@ -7,6 +7,7 @@ import cn.hutool.core.date.chinese.LunarFestival;
|
|||||||
import cn.hutool.core.date.chinese.LunarInfo;
|
import cn.hutool.core.date.chinese.LunarInfo;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
@ -151,6 +152,16 @@ public class ChineseDate {
|
|||||||
return this.year;
|
return this.year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公历的年
|
||||||
|
*
|
||||||
|
* @return 公历年
|
||||||
|
* @since 5.6.1
|
||||||
|
*/
|
||||||
|
public int getGregorianYear(){
|
||||||
|
return this.gyear;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取农历的月,从1开始计数
|
* 获取农历的月,从1开始计数
|
||||||
*
|
*
|
||||||
@ -161,6 +172,26 @@ public class ChineseDate {
|
|||||||
return this.month;
|
return this.month;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公历的月,从1开始计数
|
||||||
|
*
|
||||||
|
* @return 公历月
|
||||||
|
* @since 5.6.1
|
||||||
|
*/
|
||||||
|
public int getGregorianMonthBase1(){
|
||||||
|
return this.gmonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公历的月,从0开始计数
|
||||||
|
*
|
||||||
|
* @return 公历月
|
||||||
|
* @since 5.6.1
|
||||||
|
*/
|
||||||
|
public int getGregorianMonth(){
|
||||||
|
return this.gmonth -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前农历月份是否为闰月
|
* 当前农历月份是否为闰月
|
||||||
*
|
*
|
||||||
@ -200,6 +231,16 @@ public class ChineseDate {
|
|||||||
return this.day;
|
return this.day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公历的日
|
||||||
|
*
|
||||||
|
* @return 公历日
|
||||||
|
* @since 5.6.1
|
||||||
|
*/
|
||||||
|
public int getGregorianDay(){
|
||||||
|
return this.gday;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得农历日
|
* 获得农历日
|
||||||
*
|
*
|
||||||
@ -223,6 +264,28 @@ public class ChineseDate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公历的Date
|
||||||
|
*
|
||||||
|
* @return 公历Date
|
||||||
|
* @since 5.6.1
|
||||||
|
*/
|
||||||
|
public Date getGregorianDate(){
|
||||||
|
return DateUtil.date(getGregorianCalendar());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公历的Calendar
|
||||||
|
*
|
||||||
|
* @return 公历Calendar
|
||||||
|
* @since 5.6.1
|
||||||
|
*/
|
||||||
|
public Calendar getGregorianCalendar(){
|
||||||
|
final Calendar calendar = CalendarUtil.calendar();
|
||||||
|
//noinspection MagicConstant
|
||||||
|
calendar.set(this.gyear, getGregorianMonth(), this.gday, 0, 0, 0);
|
||||||
|
return calendar;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得节日
|
* 获得节日
|
||||||
|
@ -9,6 +9,7 @@ public class ChineseDateTest {
|
|||||||
@Test
|
@Test
|
||||||
public void chineseDateTest() {
|
public void chineseDateTest() {
|
||||||
ChineseDate date = new ChineseDate(DateUtil.parseDate("2020-01-25"));
|
ChineseDate date = new ChineseDate(DateUtil.parseDate("2020-01-25"));
|
||||||
|
Assert.assertEquals("2020-01-25 00:00:00", date.getGregorianDate().toString());
|
||||||
Assert.assertEquals(2020, date.getChineseYear());
|
Assert.assertEquals(2020, date.getChineseYear());
|
||||||
|
|
||||||
Assert.assertEquals(1, date.getMonth());
|
Assert.assertEquals(1, date.getMonth());
|
||||||
@ -50,6 +51,7 @@ public class ChineseDateTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getChineseMonthTest(){
|
public void getChineseMonthTest(){
|
||||||
ChineseDate chineseDate = new ChineseDate(2020,6,15);
|
ChineseDate chineseDate = new ChineseDate(2020,6,15);
|
||||||
|
Assert.assertEquals("2020-08-04 00:00:00", chineseDate.getGregorianDate().toString());
|
||||||
Assert.assertEquals("六月", chineseDate.getChineseMonth());
|
Assert.assertEquals("六月", chineseDate.getChineseMonth());
|
||||||
|
|
||||||
chineseDate = new ChineseDate(2020,4,15);
|
chineseDate = new ChineseDate(2020,4,15);
|
||||||
|
@ -54,6 +54,8 @@ public class DialectFactory {
|
|||||||
public static final String DRIVER_KINGBASE8 = "com.kingbase8.Driver";
|
public static final String DRIVER_KINGBASE8 = "com.kingbase8.Driver";
|
||||||
/** JDBC 驱动 Ignite thin */
|
/** JDBC 驱动 Ignite thin */
|
||||||
public static final String DRIVER_IGNITE_THIN = "org.apache.ignite.IgniteJdbcThinDriver";
|
public static final String DRIVER_IGNITE_THIN = "org.apache.ignite.IgniteJdbcThinDriver";
|
||||||
|
/** JDBC 驱动 ClickHouse */
|
||||||
|
public static final String DRIVER_CLICK_HOUSE = "ru.yandex.clickhouse.ClickHouseDriver";
|
||||||
|
|
||||||
private static final Map<DataSource, Dialect> DIALECT_POOL = new ConcurrentHashMap<>();
|
private static final Map<DataSource, Dialect> DIALECT_POOL = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@ -143,6 +145,9 @@ public class DialectFactory {
|
|||||||
} else if (nameContainsProductInfo.contains("ignite")) {
|
} else if (nameContainsProductInfo.contains("ignite")) {
|
||||||
// Ignite thin
|
// Ignite thin
|
||||||
driver = DRIVER_IGNITE_THIN;
|
driver = DRIVER_IGNITE_THIN;
|
||||||
|
} else if (nameContainsProductInfo.contains("clickhouse")) {
|
||||||
|
// ClickHouse
|
||||||
|
driver = DRIVER_CLICK_HOUSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return driver;
|
return driver;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user