Example usage for java.util Calendar DAY_OF_MONTH

List of usage examples for java.util Calendar DAY_OF_MONTH

Introduction

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

Prototype

int DAY_OF_MONTH

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

Click Source Link

Document

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

Usage

From source file:ch.cyberduck.core.ftp.parser.RumpusFTPEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;/*from w  w  w.  j ava 2  s.c o  m*/

    parsed = parser.parseFTPEntry("drwxr-xr-x               folder        0 Oct 18 13:02 Akrilik");
    assertNotNull(parsed);
    assertEquals("Akrilik", parsed.getName());
    assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType());
    assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(18, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));

    parsed = parser.parseFTPEntry("drwxrwxrwx               folder        0 Oct 11 14:53 Uploads");
    assertNotNull(parsed);
    assertEquals("Uploads", parsed.getName());
    assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType());
    assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(11, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));

    parsed = parser.parseFTPEntry("-rw-r--r--        0      589878   589878 Oct 15 13:03 WebDAV SS.bmp");
    assertNotNull(parsed);
    assertEquals("WebDAV SS.bmp", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}

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

@Override
public List<AndroidDeviceRanking> getUnidentifiedDevicesOfShuameMobile(int days)
        throws IOException, JSchException {
    SqlSession sqlSession = MyBatisHelper.getStatSqlSessionFactory().openSession();
    AndroidDeviceMapper mapper = sqlSession.getMapper(AndroidDeviceMapper.class);
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, -days);
    return mapper.selectUnidentifiedDevices(SqlUtils.getMonthlyTable("log_m_device_init"), calendar.getTime());
}

From source file:com.acc.validator.CCPaymentInfoValidator.java

@Override
public void validate(final Object target, final Errors errors) {
    final CCPaymentInfoData ccPaymentData = (CCPaymentInfoData) target;

    if (StringUtils.isNotBlank(ccPaymentData.getStartMonth())
            && StringUtils.isNotBlank(ccPaymentData.getStartYear())
            && StringUtils.isNotBlank(ccPaymentData.getExpiryMonth())
            && StringUtils.isNotBlank(ccPaymentData.getExpiryYear())) {
        final Calendar start = Calendar.getInstance();
        start.set(Calendar.DAY_OF_MONTH, 0);
        start.set(Calendar.MONTH, Integer.parseInt(ccPaymentData.getStartMonth()) - 1);
        start.set(Calendar.YEAR, Integer.parseInt(ccPaymentData.getStartYear()) - 1);

        final Calendar expiration = Calendar.getInstance();
        expiration.set(Calendar.DAY_OF_MONTH, 0);
        expiration.set(Calendar.MONTH, Integer.parseInt(ccPaymentData.getExpiryMonth()) - 1);
        expiration.set(Calendar.YEAR, Integer.parseInt(ccPaymentData.getExpiryYear()) - 1);

        if (start.after(expiration)) {
            errors.rejectValue("startMonth", "payment.startDate.invalid");
        }//from  w  ww .j  a  va2 s .  co  m
    }

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "accountHolderName", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cardType", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cardNumber", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "expiryMonth", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "expiryYear", "field.required");

    paymentAddressValidator.validate(ccPaymentData, errors);
}

From source file:org.openmeetings.test.calendar.TestDatabaseStructureAppointmentReminderTyp.java

@Test
public void testAddingGroup() {

    try {/* w w w . jav  a 2s. com*/

        Calendar cal = Calendar.getInstance();
        cal.set(2008, 9, 2);
        cal.get(Calendar.DAY_OF_MONTH);
        cal.getTime();

        appointmentReminderTypDaoImpl.addAppointmentReminderTyps(1L, "test 5 min");
        List<AppointmentReminderTyps> listAppoints = appointmentReminderTypDaoImpl
                .getAppointmentReminderTypList();

        log.debug("Anzahl: " + listAppoints.size());

        for (AppointmentReminderTyps appoints : listAppoints) {
            // log.debug("Termin: "+appoints.getAppointmentName()+" startDate: "+appoints.getAppointmentStarttime()+
            // " endDate: "+appoints.getAppointmentEndtime());
            log.debug("AppointmentReminderTyps: " + appoints.getName());
        }

        // for (Iterator<Appointment> iter =
        // listAppoints.iterator();iter.hasNext();) {
        // log.debug(iter.next());
        // }

    } catch (Exception err) {

        log.error("[testAddingGroup]", err);

    }

}

From source file:org.openmeetings.test.calendar.TestDatabaseStructureAppointment.java

@Test
public void testAddingGroup() {

    try {/*from w  w  w  .j a v  a 2s.co m*/

        Calendar cal = Calendar.getInstance();
        cal.set(2008, 9, 2);
        cal.get(Calendar.DAY_OF_MONTH);
        cal.getTime();

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = format.parse("2008-17-08");
        Date date2 = format.parse("2008-18-08");

        List<Appointment> listAppoints = appointmentDao.getAppointmentsByRange(1L, date, date2);
        //List<Appointment> listAppoints = AppointmentDaoImpl.getInstance().searchAppointmentsByName("%");
        //AppointmentDaoImpl.getInstance().getNextAppointmentById(1L);
        //AppointmentDaoImpl.getInstance().addAppointment("mezo",1L, "Pforzheim", "zweiter", Calendar.getInstance().getTime() , 
        //date, null, true, null, null, 1L,1L);
        //AppointmentDaoImpl.getInstance().addAppointment("testap", "erster Test",Calendar.getInstance().getTime() , 
        ///Calendar.getInstance().getTime(), true, false, false, false, new Long(1), 1L);
        log.debug("Anzahl: " + listAppoints.size());

        for (Appointment appoints : listAppoints) {
            log.debug("Termin: " + appoints.getAppointmentName() + " startDate: "
                    + appoints.getAppointmentStarttime() + " endDate: " + appoints.getAppointmentEndtime());
            log.debug("MeetingMembers: " + appoints.getMeetingMember().size());
        }

        for (Iterator<Appointment> iter = listAppoints.iterator(); iter.hasNext();) {
            log.debug("" + iter.next());
        }

        //AppointmentDaoImpl.getInstance().updateAppointment(1L,"neu", "erster Test",Calendar.getInstance().getTime() , 
        //Calendar.getInstance().getTime(), true, false, false, false, new Long(1));
        //log.debug("AppointmentReminderTypDaoImpl: "+appointmentReminderTypDaoImpl.getAppointmentReminderTypById(1L));
    } catch (Exception err) {

        log.error("[testAddingGroup]", err);

    }

}

From source file:ch.cyberduck.core.ftp.parser.TrellixFTPEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;//ww  w .ja  v a 2s.  c om

    //#1213
    parsed = parser.parseFTPEntry("-rw-r--r--  FTP  User       10439 Apr 20 05:29 ASCheckbox_2_0.zip");
    assertNotNull(parsed);
    assertEquals("ASCheckbox_2_0.zip", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(10439, parsed.getSize());
    assertEquals(Calendar.APRIL, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(20, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}

From source file:com.example.geomesa.authorizations.AuthorizationsTutorial.java

/**
 * Creates a base filter that will return a small subset of our results. This can be tweaked to
 * return different results if desired. Currently it should return 16 results.
 *
 * @return// w w  w. ja va2  s  .  c  om
 *
 * @throws CQLException
 * @throws IOException
 */
static Filter createBaseFilter() throws CQLException, IOException {

    // Get a FilterFactory2 to build up our query
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    // We are going to query for events in Ukraine during the
    // civil unrest.

    // We'll start by looking at a particular day in February of 2014
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(Calendar.YEAR, 2013);
    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    Date start = calendar.getTime();

    calendar.set(Calendar.YEAR, 2014);
    calendar.set(Calendar.MONTH, Calendar.APRIL);
    calendar.set(Calendar.DAY_OF_MONTH, 30);
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    Date end = calendar.getTime();
    //        2013-01-01T00:00:00.000Z/2014-04-30T23:00:00.000Z
    Filter timeFilter = ff.between(ff.property(GdeltFeature.Attributes.SQLDATE.getName()), ff.literal(start),
            ff.literal(end));

    // We'll bound our query spatially to Ukraine
    Filter spatialFilter = ff.bbox(GdeltFeature.Attributes.geom.getName(), 31.6, 44, 37.4, 47.75, "EPSG:4326");

    // we'll also restrict our query to only articles about the US, UK or UN
    Filter attributeFilter = ff.like(ff.property(GdeltFeature.Attributes.Actor1Name.getName()), "UNITED%");

    // Now we can combine our filters using a boolean AND operator
    Filter conjunction = ff.and(Arrays.asList(timeFilter, spatialFilter, attributeFilter));

    return conjunction;
}

From source file:Main.java

public static Date parseDA(TimeZone tz, String s, boolean ceil) {
    Calendar cal = cal(tz);//from  ww  w.  j a va  2s  .c  o  m
    int length = s.length();
    if (!(length == 8 || length == 10 && !Character.isDigit(s.charAt(4))))
        throw new IllegalArgumentException(s);
    try {
        int pos = 0;
        cal.set(Calendar.YEAR, Integer.parseInt(s.substring(pos, pos + 4)));
        pos += 4;
        if (!Character.isDigit(s.charAt(pos)))
            pos++;
        cal.set(Calendar.MONTH, Integer.parseInt(s.substring(pos, pos + 2)) - 1);
        pos += 2;
        if (!Character.isDigit(s.charAt(pos)))
            pos++;
        cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(s.substring(pos)));
        if (ceil)
            ceil(cal, Calendar.DAY_OF_MONTH);
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException(s);
    }
    return cal.getTime();
}

From source file:DateTimeUtil.java

/** Convert given date to string<br>
 *  OutputFormat: yyyymmdd_hhmm/*from   w ww.  ja  v  a 2s .co m*/
 *  @return The Date/Time in the format: yyyymmdd_hhmm
 */
public static String convertToDateStamp(Calendar cal) {
    String year = String.valueOf(cal.get(Calendar.YEAR));
    String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
    if (month.length() == 1) {
        month = "0" + month;
    }
    String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
    if (day.length() == 1) {
        day = "0" + day;
    }
    String hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
    if (hour.length() == 1) {
        hour = "0" + hour;
    }
    String minute = String.valueOf(cal.get(Calendar.MINUTE));
    if (minute.length() == 1) {
        minute = "0" + minute;
    }
    String second = String.valueOf(cal.get(Calendar.SECOND));
    if (second.length() == 1) {
        second = "0" + second;
    }
    String dateStamp = year + month + day + "_" + hour + minute + second;
    return dateStamp;
}

From source file:net.ceos.project.poi.annotated.bean.ObjectNullBuilder.java

/**
 * Validate the ObjectNull based on the object build with the method
 * 'buildObjectNull'//from   w  w  w. j a v  a 2 s. co  m
 * 
 * @param toValidate
 *            the object to validate
 */
public static void validateObjectNull(ObjectNull toValidate) {
    ObjectNull base = buildObjectNull();

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    Calendar calendarUnmarshal = Calendar.getInstance();
    calendarUnmarshal.setTime(toValidate.getDateAttribute());
    assertEquals(calendar.get(Calendar.YEAR), calendarUnmarshal.get(Calendar.YEAR));
    assertEquals(calendar.get(Calendar.MONTH), calendarUnmarshal.get(Calendar.MONTH));
    assertEquals(calendar.get(Calendar.DAY_OF_MONTH), calendarUnmarshal.get(Calendar.DAY_OF_MONTH));
    assertEquals(base.getStringAttribute(), toValidate.getStringAttribute());
    assertEquals(base.getIntegerAttribute(), toValidate.getIntegerAttribute());
    assertEquals(base.getDoubleAttribute(), toValidate.getDoubleAttribute());
    assertEquals(base.getLongAttribute(), toValidate.getLongAttribute());
    assertEquals(base.getBooleanAttribute(), toValidate.getBooleanAttribute());
    assertEquals(base.getJob().getJobCode(), toValidate.getJob().getJobCode());
    assertEquals(base.getJob().getJobFamily(), toValidate.getJob().getJobFamily());
    assertEquals(base.getJob().getJobName(), toValidate.getJob().getJobName());
    assertEquals(base.getIntegerPrimitiveAttribute(), toValidate.getIntegerPrimitiveAttribute());
    assertEquals(base.getDoublePrimitiveAttribute(), toValidate.getDoublePrimitiveAttribute());
    assertEquals(base.getLongPrimitiveAttribute(), toValidate.getLongPrimitiveAttribute());
    assertEquals(base.isBooleanPrimitiveAttribute(), toValidate.isBooleanPrimitiveAttribute());
    assertEquals(base.getAddressInfo().getAddress(), toValidate.getAddressInfo().getAddress());
    assertEquals(base.getAddressInfo().getNumber(), toValidate.getAddressInfo().getNumber());
    assertEquals(base.getAddressInfo().getCity(), toValidate.getAddressInfo().getCity());
    assertEquals(base.getAddressInfo().getCityCode(), toValidate.getAddressInfo().getCityCode());
    assertEquals(base.getAddressInfo().getCountry(), toValidate.getAddressInfo().getCountry());
    assertEquals(base.getFloatAttribute(), toValidate.getFloatAttribute());
    assertEquals(base.getFloatPrimitiveAttribute(), toValidate.getFloatPrimitiveAttribute());
    assertEquals(base.getUnitFamily(), toValidate.getUnitFamily());
    assertEquals(base.getBigDecimalAttribute(), toValidate.getBigDecimalAttribute());
    assertEquals(base.getShortAttribute(), toValidate.getShortAttribute());
    assertEquals(base.getShortPrimitiveAttribute(), toValidate.getShortPrimitiveAttribute());
    // TODO add new validation below
}