Example usage for java.util Calendar DATE

List of usage examples for java.util Calendar DATE

Introduction

In this page you can find the example usage for java.util Calendar DATE.

Prototype

int DATE

To view the source code for java.util Calendar DATE.

Click Source Link

Document

Field number for get and set indicating the day of the month.

Usage

From source file:com.cemeterylistingswebtest.test.domain.PublishedDeceasedListingTest.java

@Test
public void create() {
    repoList = ctx.getBean(PublishedDeceasedListingRepository.class);

    System.out.println("Published Deceased Listings Test");
    repoList = ctx.getBean(PublishedDeceasedListingRepository.class);
    subRepo = ctx.getBean(SubscriberRepository.class);
    userRepo = ctx.getBean(UserRoleRepository.class);

    //Initialise date
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2008);
    calendar.set(Calendar.MONTH, Calendar.FEBRUARY);
    calendar.set(Calendar.DATE, 4);

    java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime());

    //Initialise user role                
    UserRole userRole = new UserRole.Builder().setLevel(1).build();
    //userRepo.save(userRole);
    //userRoleID = userRole.getUserRoleID();

    //Initialise subscriber
    Subscriber newSub = new Subscriber.Builder().setEmail("manfredOsulivan@horseRaddish.com")
            .setFirstName("Manfred").setSurname("Osulivan").setPwd("jesus").setUsername("ManiFredOssy")
            .setSubscriptionDate(javaSqlDate).setUserRoleID(userRole).build();
    subRepo.save(newSub);/*from ww  w  . j  ava 2 s .  c o m*/
    subID = newSub.getSubscriberID();

    PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Hendrika")
            .setSurname("Fourie").setMaidenName("Gerber").setGender("Female").setDateOfBirth("08/06/1969")
            .setDateOfDeath("14/02/2005").setGraveInscription("Hippiest person eva").setGraveNumber("2456")
            .setImageOfBurialSite("/images/001.jpg").setLastKnownContactName("Berry")
            .setLastKnownContactNumber("0725576482").setSubscriberSubmitID(subID).build();

    repoList.save(newListing);
    id = newListing.getPublishedListingID();
}

From source file:com.springmvc.videoteca.spring.dao.PeliculaDAOImpl.java

private Date obtenerSemanaAnterior() {
    Calendar c;/*  w  ww  .  ja  va 2s .c o  m*/
    int dia;
    c = Calendar.getInstance();
    dia = c.get(Calendar.DATE);
    c.set(Calendar.DATE, dia - 7);
    return c.getTime();
}

From source file:org.jasig.portlet.ClassifiedsPortlet.domain.SubmitAdFormValidator.java

public void validate(Object target, Errors errors) {

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "category", "required.category");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", "required.title");
    ValidationUtils.rejectIfEmpty(errors, "startDate", "required.startDate");
    ValidationUtils.rejectIfEmpty(errors, "endDate", "required.endDate");
    ValidationUtils.rejectIfEmpty(errors, "description", "required.description");

    Ad form = (Ad) target;/* ww w  .  j  a  v a2s .  c o  m*/

    if (form.getPolicyAccepted() == false) {

        errors.rejectValue("policyAccepted", "required.policyAccepted");
    }

    if (form.getStartDate() != null && form.getEndDate() != null
            && !form.getStartDate().before(form.getEndDate())) {
        errors.rejectValue("startDate", "invalid.startDateAfterEndDate");
    }

    Calendar cal = Calendar.getInstance();
    Date today = new Date();

    cal.setTime(today);
    cal.add(Calendar.DATE, 60);
    Date maxStartDate = cal.getTime();

    if (form.getStartDate() != null && form.getStartDate().after(maxStartDate)) {
        errors.rejectValue("startDate", "invalid.startDatePastMaximumDays");
    }

    cal.setTime(today);
    cal.add(Calendar.DATE, 120);
    Date maxEndDate = cal.getTime();

    if (form.getEndDate() != null && form.getEndDate().after(maxEndDate)) {
        errors.rejectValue("startDate", "invalid.endDatePastMaximumDays");
    }

    if (form.getDescription().length() > 2056) {
        errors.rejectValue("description", "tolong.description");
    }
    ;

    if (form.getCategory() == null) {
        errors.rejectValue("category", "required.category");
    }
    ;

}

From source file:com.yukthi.validators.FutureOrTodayValidator.java

@Override
public boolean isValid(Date targetDate, ConstraintValidatorContext context) {
    //if target date is not present, ignore validator
    if (targetDate == null) {
        return true;
    }//from   www .  j  a  va  2  s  .  c om

    //compare target date with today
    Date today = DateUtils.truncate(new Date(), Calendar.DATE);
    targetDate = DateUtils.truncate(targetDate, Calendar.DATE);

    return (targetDate.compareTo(today) >= 0);
}

From source file:org.openmrs.module.radiology.web.controller.queue.RescheduleTestController.java

@RequestMapping(method = RequestMethod.GET)
public String showRescheduleForm(Model model, @RequestParam(value = "type", required = false) String type,
        @ModelAttribute("order") Order order) {
    if (order != null) {
        TestModel tm = RadiologyUtil.generateModel(order, null);
        model.addAttribute("test", tm);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, 1);
        model.addAttribute("currentDate", RadiologyUtil.formatDate(c.getTime()));
    }//w w w  . j  av  a2s. c  o  m
    if (!StringUtils.isBlank(type)) {
        if (type.equalsIgnoreCase("reorder")) {
            return "/module/radiology/worklist/reOrder";
        }
    }
    return "/module/radiology/queue/rescheduleForm";
}

From source file:com.cemeterylistingswebtest.test.domain.RequiresApprovalDeceasedListingTest.java

@Test
public void create() {
    System.out.println("Requires Approval Deceased Listing Test");
    repoList = ctx.getBean(RequiresApprovalDeceasedListingRepository.class);
    subRepo = ctx.getBean(SubscriberRepository.class);
    userRepo = ctx.getBean(UserRoleRepository.class);

    //Initialise date
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2008);
    calendar.set(Calendar.MONTH, Calendar.FEBRUARY);
    calendar.set(Calendar.DATE, 4);

    java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime());

    //Initialise user role                
    UserRole userRole = new UserRole.Builder().setLevel(1).build();
    //userRepo.save(userRole);
    //userRoleID = userRole.getUserRoleID();

    //Initialise subscriber
    Subscriber newSub = new Subscriber.Builder().setEmail("manfredOsulivan@horseRaddish.com")
            .setFirstName("Manfred").setSurname("Osulivan").setPwd("jesus").setUsername("ManiFredOssy")
            .setSubscriptionDate(javaSqlDate).setUserRoleID(userRole).build();
    subRepo.save(newSub);/*from   w  w  w. j  a  va  2  s  .c  o m*/
    subID = newSub.getSubscriberID();

    //Finally Initialise RequiresApprovalDeceasedListing
    RequiresApprovalDeceasedListing newListing = new RequiresApprovalDeceasedListing.Builder()
            .setFirstName("Hendrika").setSurname("Fourie").setMaidenName("Gerber").setGender("Female")
            .setDateOfBirth("08/06/1969").setDateOfDeath("14/02/2005")
            .setGraveInscription("Hippiest person eva").setGraveNumber("2456")
            .setImageOfBurialSite("/images/001.jpg").setLastKnownContactName("Berry")
            .setLastKnownContactNumber("0725576482").setSubscriberSubmitID(subID)
            //cemetery id

            //names

            .build();

    repoList.save(newListing);
    id = newListing.getRequiresApprovalDeceasedListingID();
}

From source file:com.cemeterylistingswebtest.test.services.approveDeceasedListingServiceTest.java

@Test
public void Test() {

    //deadRepo = ctx.getBean(RequiresApprovalDeceasedListingRepository.class);
    adserv = ctx.getBean(ApproveDeceasedListingService.class);
    repo = ctx.getBean(SubscriberRepository.class);
    repoList = ctx.getBean(RequiresApprovalDeceasedListingRepository.class);
    userRepo = ctx.getBean(UserRoleRepository.class);

    //Initialise date
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2010);
    calendar.set(Calendar.MONTH, Calendar.JUNE);
    calendar.set(Calendar.DATE, 14);

    java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime());

    //Initialise user role                
    UserRole userRole = new UserRole.Builder().setLevel(2).build();
    //Initialise subscriber
    Subscriber newSub = new Subscriber.Builder().setEmail("greaper@gmail.com").setFirstName("Grim")
            .setSurname("reaper").setPwd("souls").setUsername("greaper").setSubscriptionDate(javaSqlDate)
            .setUserRoleID(userRole).build();
    repo.save(newSub);/*  w  w  w .  j a v a 2s .c  o m*/
    subID = newSub.getSubscriberID();

    //Finally Initialise RequiresApprovalDeceasedListing
    RequiresApprovalDeceasedListing newListing = new RequiresApprovalDeceasedListing.Builder()
            .setFirstName("elizabeth").setSurname("willow").setMaidenName("charles").setGender("Female")
            .setDateOfBirth("16/06/1960").setDateOfDeath("14/011/2014")
            .setGraveInscription("lived long and prospered").setGraveNumber("2811")
            .setImageOfBurialSite("/images/003.jpg")

            .setSubscriberSubmitID(subID)
            //cemetery id

            //names

            .build();

    repoList.save(newListing);
    id = newListing.getRequiresApprovalDeceasedListingID();
    boolean approve = adserv.approveDeceasedListing(id);
    Assert.assertFalse(approve);
    repoList.delete(newListing);
    repo.delete(newSub);

}

From source file:org.openmrs.module.laboratory.web.controller.queue.RescheduleTestController.java

@RequestMapping(method = RequestMethod.GET)
public String showRescheduleForm(Model model, @RequestParam(value = "type", required = false) String type,
        @ModelAttribute("order") Order order) {
    if (order != null) {
        TestModel tm = LaboratoryUtil.generateModel(order, null);
        model.addAttribute("test", tm);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, 1);
        model.addAttribute("currentDate", LaboratoryUtil.formatDate(c.getTime()));
    }//from  w w w.j  a va2  s  .co  m
    if (!StringUtils.isBlank(type)) {
        if (type.equalsIgnoreCase("reorder")) {
            return "/module/laboratory/worklist/reOrder";
        }
    }
    return "/module/laboratory/queue/rescheduleForm";
}

From source file:com.u2apple.tool.dao.AndroidDeviceDaoImpl.java

@Override
public List<AndroidDeviceRanking> getUnidentifiedDevicesOfRootSpirit(int days)
        throws IOException, JSchException {
    SqlSession sqlSession = MyBatisHelper.getRootSqlSessionFactory().openSession();
    RootDeviceMapper mapper = sqlSession.getMapper(RootDeviceMapper.class);
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, -days);
    calendar = DateUtils.truncate(calendar, Calendar.DATE);
    return mapper.selectUnidentifiedDevices(SqlUtils.getMonthlyTable("log_root_solution"), calendar.getTime());
}

From source file:com.mozilla.socorro.RawDumpSizeScan.java

/**
 * Generates an array of scans for different salted ranges for the given dates
 * @param startDate/*from w w  w .java2  s  .  c o  m*/
 * @param endDate
 * @return
 */
public static Scan[] generateScans(Calendar startCal, Calendar endCal) {
    SimpleDateFormat rowsdf = new SimpleDateFormat("yyMMdd");

    ArrayList<Scan> scans = new ArrayList<Scan>();
    String[] salts = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e",
            "f" };

    long endTime = DateUtil.getEndTimeAtResolution(endCal.getTimeInMillis(), Calendar.DATE);

    while (startCal.getTimeInMillis() < endTime) {
        int d = Integer.parseInt(rowsdf.format(startCal.getTime()));

        for (int i = 0; i < salts.length; i++) {
            Scan s = new Scan();
            s.setCaching(4);
            // disable block caching
            s.setCacheBlocks(false);
            s.addColumn(RAW_DATA_BYTES, DUMP_BYTES);

            s.setStartRow(Bytes.toBytes(salts[i] + String.format("%06d", d)));
            s.setStopRow(Bytes.toBytes(salts[i] + String.format("%06d", d + 1)));
            System.out.println("Adding start-stop range: " + salts[i] + String.format("%06d", d) + " - "
                    + salts[i] + String.format("%06d", d + 1));

            scans.add(s);
        }

        startCal.add(Calendar.DATE, 1);
    }

    return scans.toArray(new Scan[scans.size()]);
}