sample.util.DateUtils Java Examples

The following examples show how to use sample.util.DateUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CashInOutTest.java    From ddd-java with MIT License 6 votes vote down vote up
@Test
public void find() {
    tx(() -> {
        CashInOut cio = fixtures.cio(accId, "300", true);
        cio.setUpdateDate(DateUtils.date("20141118"));
        cio.save(rep);
        // low: ちゃんとやると大変なので最低限の検証
        assertEquals(
                1,
                CashInOut.find(rep, findParam("20141118", "20141119")).size());
        assertEquals(
                1,
                CashInOut.find(rep, findParam("20141118", "20141119", ActionStatusType.UNPROCESSED)).size());
        assertTrue(
                CashInOut.find(rep, findParam("20141118", "20141119", ActionStatusType.PROCESSED)).isEmpty());
        assertTrue(
                CashInOut.find(rep, findParam("20141119", "20141120", ActionStatusType.UNPROCESSED)).isEmpty());
    });
}
 
Example #2
Source File: HolidayTest.java    From sample-boot-micro with MIT License 5 votes vote down vote up
@Test
public void 休日を登録する() {
    List<RegHolidayItem> items = Arrays.asList("2016-09-21", "2016-09-22", "2016-09-23")
            .stream().map((s) -> new RegHolidayItem(DateUtils.day(s), "休日")).collect(Collectors.toList());
    tx(() -> {
        Holiday.register(rep, new RegHoliday(2016, items));
        assertThat(Holiday.find(rep, 2016), hasSize(3));
    });
}
 
Example #3
Source File: HolidayTest.java    From sample-boot-hibernate with MIT License 5 votes vote down vote up
@Test
public void 休日を登録する() {
    List<RegHolidayItem> items = Arrays.asList("2016-09-21", "2016-09-22", "2016-09-23")
            .stream()
            .map((s) -> new RegHolidayItem(DateUtils.day(s), "休日"))
            .collect(Collectors.toList());
    tx(() -> {
        Holiday.register(rep, new RegHoliday(2016, items));
        assertEquals(3, Holiday.find(rep, 2016).size());
    });
}
 
Example #4
Source File: AuditEvent.java    From sample-boot-hibernate with MIT License 5 votes vote down vote up
/** イベント監査ログを検索します。 */
public static PagingList<AuditEvent> find(final SystemRepository rep, final FindAuditEvent p) {
    return rep.tmpl().find(AuditEvent.class, (criteria) -> {
        return criteria
                .equal("category", p.category)
                .equal("statusType", p.statusType)
                .like(new String[] { "message", "errorReason" }, p.keyword, MatchMode.ANYWHERE)
                .between("startDate", p.fromDay.atStartOfDay(), DateUtils.dateTo(p.toDay));
    }, p.page.sortIfEmpty(SortOrder.desc("startDate")));
}
 
Example #5
Source File: AuditEvent.java    From sample-boot-hibernate with MIT License 5 votes vote down vote up
/** イベント監査ログを例外状態にします。 */
public AuditEvent error(final SystemRepository rep, String errorReason) {
    LocalDateTime now = rep.dh().time().date();
    setStatusType(ActionStatusType.Error);
    setErrorReason(StringUtils.abbreviate(errorReason, 250));
    setEndDate(now);
    setTime(DateUtils.between(startDate, endDate).get().toMillis());
    return update(rep);
}
 
Example #6
Source File: AuditEvent.java    From sample-boot-hibernate with MIT License 5 votes vote down vote up
/** イベント監査ログを取消状態にします。 */
public AuditEvent cancel(final SystemRepository rep, String errorReason) {
    LocalDateTime now = rep.dh().time().date();
    setStatusType(ActionStatusType.Cancelled);
    setErrorReason(StringUtils.abbreviate(errorReason, 250));
    setEndDate(now);
    setTime(DateUtils.between(startDate, endDate).get().toMillis());
    return update(rep);
}
 
Example #7
Source File: AuditEvent.java    From sample-boot-hibernate with MIT License 5 votes vote down vote up
/** イベント監査ログを完了状態にします。 */
public AuditEvent finish(final SystemRepository rep) {
    LocalDateTime now = rep.dh().time().date();
    setStatusType(ActionStatusType.Processed);
    setEndDate(now);
    setTime(DateUtils.between(startDate, endDate).get().toMillis());
    return update(rep);
}
 
Example #8
Source File: AuditEvent.java    From sample-boot-micro with MIT License 5 votes vote down vote up
/** イベント監査ログを完了状態にします。 */
public AuditEvent finish(final SystemRepository rep) {
    LocalDateTime now = rep.dh().time().date();
    setStatusType(ActionStatusType.Processed);
    setEndDate(now);
    setTime(DateUtils.between(startDate, endDate).get().toMillis());
    return update(rep);
}
 
Example #9
Source File: DataFixtures.java    From sample-boot-micro with MIT License 5 votes vote down vote up
/** 祝日の簡易生成 */
public Holiday holiday(String dayStr) {
    Holiday m = new Holiday();
    m.setCategory(Holiday.CategoryDefault);
    m.setName("休日サンプル");
    m.setDay(DateUtils.day(dayStr));
    return m;
}
 
Example #10
Source File: AuditEvent.java    From sample-boot-micro with MIT License 5 votes vote down vote up
/** イベント監査ログを検索します。 */
public static PagingList<AuditEvent> find(final SystemRepository rep, final FindAuditEvent p) {
    return rep.tmpl().find(AuditEvent.class, (criteria) -> {
        return criteria
                .equal("category", p.category)
                .equal("statusType", p.statusType)
                .like(new String[] { "message", "errorReason" }, p.keyword, MatchMode.ANYWHERE)
                .between("startDate", p.fromDay.atStartOfDay(), DateUtils.dateTo(p.toDay));
    }, p.page.sortIfEmpty(SortOrder.desc("startDate")));
}
 
Example #11
Source File: AuditEvent.java    From sample-boot-micro with MIT License 5 votes vote down vote up
/** イベント監査ログを例外状態にします。 */
public AuditEvent error(final SystemRepository rep, String errorReason) {
    LocalDateTime now = rep.dh().time().date();
    setStatusType(ActionStatusType.Error);
    setErrorReason(StringUtils.abbreviate(errorReason, 250));
    setEndDate(now);
    setTime(DateUtils.between(startDate, endDate).get().toMillis());
    return update(rep);
}
 
Example #12
Source File: AuditEvent.java    From sample-boot-micro with MIT License 5 votes vote down vote up
/** イベント監査ログを取消状態にします。 */
public AuditEvent cancel(final SystemRepository rep, String errorReason) {
    LocalDateTime now = rep.dh().time().date();
    setStatusType(ActionStatusType.Cancelled);
    setErrorReason(StringUtils.abbreviate(errorReason, 250));
    setEndDate(now);
    setTime(DateUtils.between(startDate, endDate).get().toMillis());
    return update(rep);
}
 
Example #13
Source File: Holiday.java    From sample-boot-micro with MIT License 4 votes vote down vote up
/** 休日マスタを登録します。 */
public static void register(final OrmRepository rep, final RegHoliday p) {
    rep.tmpl().execute("delete from Holiday h where h.category=?1 and h.day between ?2 and ?3",
            p.category, LocalDate.ofYearDay(p.year, 1), DateUtils.dayTo(p.year));
    p.list.forEach(v -> v.create(p).save(rep));
}
 
Example #14
Source File: Holiday.java    From sample-boot-micro with MIT License 4 votes vote down vote up
public static List<Holiday> find(final OrmRepository rep, final int year, final String category) {
    return rep.tmpl().find("from Holiday h where h.category=?1 and h.day between ?2 and ?3 order by h.day",
            category, LocalDate.ofYearDay(year, 1), DateUtils.dayTo(year));
}
 
Example #15
Source File: DataFixtures.java    From sample-boot-micro with MIT License 4 votes vote down vote up
public void initializeInTxSystem() {
    String day = DateUtils.dayFormat(LocalDate.now());
    new AppSetting(Timestamper.KeyDay, "system", "営業日", day).save(repSystem);
}
 
Example #16
Source File: BusinessDayHandler.java    From sample-boot-micro with MIT License 4 votes vote down vote up
/** 祝日もしくは週末時はtrue。 */
private boolean isHolidayOrWeeekDay(LocalDate day) {
    return (DateUtils.isWeekend(day) || isHoliday(day));
}
 
Example #17
Source File: BusinessDayHandler.java    From sample-boot-hibernate with MIT License 4 votes vote down vote up
/** 祝日もしくは週末時はtrue。 */
private boolean isHolidayOrWeeekDay(LocalDate day) {
    return (DateUtils.isWeekend(day) || isHoliday(day));
}
 
Example #18
Source File: Holiday.java    From sample-boot-hibernate with MIT License 4 votes vote down vote up
public static List<Holiday> find(final OrmRepository rep, final int year, final String category) {
    return rep.tmpl().find("from Holiday h where h.category=?1 and h.day between ?2 and ?3 order by h.day",
            category, LocalDate.ofYearDay(year, 1), DateUtils.dayTo(year));
}
 
Example #19
Source File: Holiday.java    From sample-boot-hibernate with MIT License 4 votes vote down vote up
/** 休日マスタを登録します。 */
public static void register(final OrmRepository rep, final RegHoliday p) {
    rep.tmpl().execute("delete from Holiday h where h.category=?1 and h.day between ?2 and ?3",
            p.category, LocalDate.ofYearDay(p.year, 1), DateUtils.dayTo(p.year));
    p.list.forEach(v -> v.create(p).save(rep));
}