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.UnixFTPEntryParserTest.java

@Test
public void testParseTimestamp() {
    FTPFileEntryParser parser = new FTPParserSelector().getParser("UNIX");

    FTPFile parsed;/*www .  jav  a  2  s  . c om*/

    parsed = parser
            .parseFTPEntry("drw-rw-rw-   1 user      ftp             0  DEC 11 20:56 ADMIN_Documentation");
    assertNotNull(parsed);
    assertNotNull(parsed.getTimestamp());
    assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(11, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertEquals(20, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY));
    assertEquals(56, parsed.getTimestamp().get(Calendar.MINUTE));

    parsed = parser.parseFTPEntry("drwxr-xr-x    3 ftp      ftp           512 Mar 15  2004 doc");
    assertNotNull(parsed);
    assertNotNull(parsed.getTimestamp());
    assertEquals(2004, parsed.getTimestamp().get(Calendar.YEAR));
    assertEquals(Calendar.MARCH, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));

    parsed = parser.parseFTPEntry("drwxrwxr-x    2 ftp      ftp           512 Oct 23  2007 aurox");
    assertNotNull(parsed);
    assertNotNull(parsed.getTimestamp());
    assertEquals(2007, parsed.getTimestamp().get(Calendar.YEAR));
    assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(23, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
}

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

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

    parsed = parser.parseFTPEntry("-rwx------          17      332      640 Dec 20 08:54 file 1");
    assertNotNull(parsed);
    assertEquals("file 1", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(640, parsed.getSize());

    parsed = parser.parseFTPEntry("drwx------             folder          2 Dec 20 08:55 folder1");
    assertNotNull(parsed);
    assertEquals("folder1", parsed.getName());
    assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType());
    assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(20, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertFalse(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));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}

From source file:org.wikipedia.nirvana.statistics.ArchiveItem.java

public ArchiveItem(Revision r) {
    this.article = HTTPTools.removeEscape(r.getPage());
    this.user = HTTPTools.removeEscape(r.getUser());
    Calendar c = r.getTimestamp();
    this.year = c.get(Calendar.YEAR);
    this.month = c.get(Calendar.MONTH);
    this.day = c.get(Calendar.DAY_OF_MONTH);
    this.size = r.getSize();
}

From source file:com.cip.crane.zookeeper.common.infochannel.ZooKeeperReader.java

public void run(int offset) {
    Date date = new Date();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);//from w  ww . j  a va2  s .c  o m
    calendar.add(Calendar.DAY_OF_MONTH, offset);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    String dateString = format.format(calendar.getTime());
    List<String> ipList = null;
    try {
        ipList = readChannel.getChildrenNodeName(null, SCHEDULE_PATH);

    } catch (KeeperException e) {
        LOGGER.error(e, e);
        return;
    } catch (InterruptedException e) {
        LOGGER.error(e, e);
        return;
    }
    for (String ip : ipList) {
        List<String> attemptList = null;
        try {
            attemptList = readChannel.getChildrenNodeName(null, SCHEDULE_PATH + "/" + ip + "/" + dateString);

        } catch (KeeperException e) {
            LOGGER.error(e, e);
            continue;
        } catch (InterruptedException e) {
            LOGGER.error(e, e);
            continue;
        }
        for (String attemptId : attemptList) {

            if (!zkChannel.rmrPath("/" + SCHEDULE_PATH + "/" + ip + "/" + attemptId)) {
                LOGGER.error("faile to delete " + SCHEDULE_PATH + "/" + ip + "/" + attemptId);
            }

        }
        zkChannel.rmrPath("/" + SCHEDULE_PATH + "/" + ip + "/" + dateString);

    }

}

From source file:de.dekarlab.moneybuilder.model.parser.JsonBookLoader.java

/**
 * Load book from JSON file./*from   w ww.j  a v  a 2  s .c  o m*/
 * 
 * @return
 */
public static Book loadBook(File file) throws Exception {
    Book book = new Book();
    if (!file.exists()) {
        book.setName("Book");
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(new Date());
        cal.set(Calendar.DAY_OF_MONTH, 1);
        // create period
        Period newPeriod = new Period(cal.getTime());
        newPeriod.setId(Formatter.formatDateId(cal.getTime()));
        book.getPeriodList().add(newPeriod);
        book.setCurrPeriod(newPeriod);
        book.getAssetList().setName(App.getGuiProp("default.assets"));
        book.getLiabilityList().setName(App.getGuiProp("default.liability"));
        book.getExpenseList().setName(App.getGuiProp("default.expenses"));
        book.getIncomeList().setName(App.getGuiProp("default.income"));
        return book;
    }
    FileReader fr = null;
    try {
        fr = new FileReader(file);
        JSONTokener jsonTokener = new JSONTokener(fr);
        JSONObject root = new JSONObject(jsonTokener);
        JSONObject jsonBook = root.getJSONObject("book");
        book.setName(jsonBook.getString("name"));
        book.setCurrPeriodId(jsonBook.getString("currPeriodId"));
        parseAccounts(jsonBook.getJSONObject("assets"), book.getAssetList());
        parseAccounts(jsonBook.getJSONObject("liability"), book.getLiabilityList());
        parseAccounts(jsonBook.getJSONObject("income"), book.getIncomeList());
        parseAccounts(jsonBook.getJSONObject("expenses"), book.getExpenseList());
        parsePeriods(jsonBook.getJSONArray("periodList"), book.getPeriodList(), book);
    } finally {
        if (fr != null) {
            fr.close();
        }
    }
    return book;
}

From source file:ru.org.linux.search.SearchControlController.java

@RequestMapping(value = "/admin/search-reindex", method = RequestMethod.POST, params = "action=all")
@PreAuthorize("hasRole('ROLE_ADMIN')")
public ModelAndView reindexAll(ServletRequest request) throws Exception {

    Timestamp startDate = messageDao.getTimeFirstTopic();

    Calendar start = Calendar.getInstance();
    start.setTime(startDate);/*w  w w.  j  a  v  a  2  s  .c  om*/

    start.set(Calendar.DAY_OF_MONTH, 1);
    start.set(Calendar.HOUR, 0);
    start.set(Calendar.MINUTE, 0);

    for (Calendar i = Calendar.getInstance(); i.after(start); i.add(Calendar.MONTH, -1)) {
        searchQueueSender.updateMonth(i.get(Calendar.YEAR), i.get(Calendar.MONTH) + 1);
    }

    searchQueueSender.updateMonth(1970, 1);

    return new ModelAndView("action-done", "message", "Scheduled reindex");
}

From source file:br.com.pontocontrol.controleponto.ExtObject.java

protected static int getDiaAtual() {
    return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
}

From source file:com.ekom.ekomerp.global.DateTimeUtils.java

public static Date getFirstDayOfMonth(Date date) {
    Calendar calendar = getCalendarWithoutTime(date);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    return calendar.getTime();
}

From source file:org.atomspace.ultrahouse3000.translator.Message2DocumentTranslator.java

void addCalenderInformation(Message message) {
    Calendar cal = Calendar.getInstance();
    message.setHeader("timestamp", cal.getTimeInMillis());
    message.setHeader("calendarYear", cal.get(Calendar.YEAR));
    message.setHeader("calendarDayOfMonth", cal.get(Calendar.DAY_OF_MONTH));
    message.setHeader("calendarMonth", cal.get(Calendar.MONTH));
    message.setHeader("calendarDayOfYear", cal.get(Calendar.DAY_OF_YEAR));
    message.setHeader("calendarHourOfDay", cal.get(Calendar.HOUR_OF_DAY));
    message.setHeader("calendarMinute", cal.get(Calendar.MINUTE));
    message.setHeader("calendarSecond", cal.get(Calendar.SECOND));
    message.setHeader("calendarWeekOfYear", cal.get(Calendar.WEEK_OF_YEAR));
    message.setHeader("calendarDayOfWeek", cal.get(Calendar.DAY_OF_WEEK));

}

From source file:Main.java

public static Date getDateTimeFrom(Date iDate, int mode, int adddate) {

    Calendar calendar = Calendar.getInstance();
    Calendar calendarDate = Calendar.getInstance();
    calendarDate.setTime(iDate);/* w  w w.  j a  v  a  2  s  .c  o  m*/

    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    switch (mode) {

    case Calendar.DAY_OF_MONTH: {
        calendar.set(Calendar.DAY_OF_MONTH, calendarDate.get(Calendar.DAY_OF_MONTH) + adddate);
    }
        break;

    }
    Date ret = calendar.getTime();
    Log.v("!!!!!!!!!! calendar=", "" + ret);

    return ret;
}