Java Code Examples for org.joda.time.LocalDate.now()

The following are Jave code examples for showing how to use now() of the org.joda.time.LocalDate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: yum   File: DailyMenuService.java   Source Code and License Vote up 6 votes
/**
 * @return a list to the chef, of Daily Menus of the current month
 */
@PreAuthorize("hasAuthority('chef')")
public List<DailyMenuChef> dailyMenusMonthlyGet()
{

    LocalDate today = LocalDate.now();
    LocalDate startOfMonth = today.dayOfMonth().withMinimumValue();
    int daysOfMonth = today.dayOfMonth().withMaximumValue().getDayOfMonth();
    List<DailyMenuChef> monthlyMenu = new ArrayList<>();
    for (int i = 0; i < daysOfMonth; i++)
    {
        if (getDailyMenuChef(startOfMonth).getDate() != null)
            monthlyMenu.add(getDailyMenuChef(startOfMonth));
        startOfMonth = startOfMonth.plusDays(1);
    }
    return monthlyMenu;
}
 
Example 2
Project: real-time-risk   File: OptionPricer.java   Source Code and License Vote up 6 votes
protected double fv() {

        double spot = cache.marketPrices.getUnchecked(marketPriceKey).getLastPrice();
        double sigma = cache.vols.getUnchecked(volKey).getValue();
        double riskFreeRate = cache.intRates.getUnchecked(interestRateKey).getValue();
        double strike = instrument.getStrike();

        //TODO Enhancement, allow use the asOf time from ValuationRequest for asofPricing
        LocalDate now = LocalDate.now();
        double time = ((double) Days.daysBetween(now, LocalDate.parse(Integer.toString(instrument.getExpDate()), FORMAT)).getDays()) / DAY_IN_YEAR;

        if (instrument.getOptionType() == Instrument.OptionType.P) {
            return putPrice(spot, strike, riskFreeRate, sigma, time);

        } else {
            return callPrice(spot, strike, riskFreeRate, sigma, time);
        }
    }
 
Example 3
Project: yum   File: MenusService.java   Source Code and License Vote up 5 votes
@Transactional
public List<DailyMenu> menusWeeklyGet(Long userId) throws ApiException, Exception {
    LocalDate today = LocalDate.now();
    LocalDate firstDayOfWeek = today.minusDays(today.getDayOfWeek() - 1);
    List<com.jrtechnologies.yum.api.model.DailyMenu> weeklyMenu = new ArrayList<>();
    for (int i = 0; i < 7; i++) {
        DailyMenu dailymenu = createWeekDailyMenu(firstDayOfWeek.plusDays(i), userId);
        if (dailymenu.getDate() != null) {
            weeklyMenu.add(dailymenu);
        }
    }
    return weeklyMenu;
}
 
Example 4
Project: yum   File: MenusService.java   Source Code and License Vote up 5 votes
@Transactional
public List<DailyMenu> menusMonthlyGet(@ApiParam(value = "") @RequestParam(value = "stats", required = false) Long userId) throws ApiException, Exception {
    LocalDate today = LocalDate.now();
    LocalDate startOfMonth = today.dayOfMonth().withMinimumValue();
    int daysOfMonth = today.dayOfMonth().withMaximumValue().getDayOfMonth();
    List<DailyMenu> monthlyMenu = new ArrayList<>();
    for (int i = 0; i < daysOfMonth; i++) {
        DailyMenu dailymenu = createOrderedDailyMenu(startOfMonth.plusDays(i), userId);
        if (dailymenu.getDate() != null) {
            monthlyMenu.add(dailymenu);
        }
    }
    return monthlyMenu;
}
 
Example 5
Project: moneytracking   File: ArchiveActivity.java   Source Code and License Vote up 5 votes
private void init_list() {
    moneyItemDao = dbHelper.getDaoSession().getMoneyItemDao();
    input = new ArrayList<>();
    LocalDate dt = new LocalDate(LocalDate.now());

    recyclerView = (RecyclerView) findViewById(R.id.recyclerview_archive);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    input = moneyItemDao.queryBuilder().where(MoneyItemDao.Properties.Date.between(new Date(0), dt.toDate())).list();

    adapter = new MoneyItemAdapter(input);
    recyclerView.setAdapter(adapter);
}
 
Example 6
Project: alfresco-remote-api   File: StatsGet.java   Source Code and License Vote up 5 votes
/**
 * Parses ISO8601 formatted Date Strings.
 * @param start If start is null then defaults to 1 month
 * @param end If end is null then it defaults to now();
 */
public static Pair<LocalDate, LocalDate> getStartAndEndDates(String start, String end)
{
    if (start == null) return null;
    LocalDate startDate = LocalDate.parse(start);
    LocalDate endDate = end!=null?LocalDate.parse(end):LocalDate.now();
    return new Pair<LocalDate, LocalDate>(startDate, endDate);
}
 
Example 7
Project: alfresco-remote-api   File: StatsGetTest.java   Source Code and License Vote up 5 votes
@Test
public void testGetStartAndEndDates()
{
    LocalDate currentDate = LocalDate.now();
    Pair<LocalDate, LocalDate> dates = StatsGet.getStartAndEndDates(null, null);
    assertNull(dates);
    
    String test1 = "2014-05-01";
    String test2 = "2015-06-30";
    dates = StatsGet.getStartAndEndDates(test1, null);
    assertNotNull(dates);
    assertEquals(2014, dates.getFirst().getYear());
    assertEquals(5, dates.getFirst().getMonthOfYear());
    assertEquals(1, dates.getFirst().getDayOfMonth());
    assertEquals(currentDate, dates.getSecond());
    
    dates = StatsGet.getStartAndEndDates(null, test2);
    assertNull(dates);
    
    dates = StatsGet.getStartAndEndDates(test1, test2);
    assertNotNull(dates);
    assertEquals(2014, dates.getFirst().getYear());
    assertEquals(5, dates.getFirst().getMonthOfYear());
    assertEquals(1, dates.getFirst().getDayOfMonth());
    assertNotNull(dates);
    assertEquals(2015, dates.getSecond().getYear());
    assertEquals(6, dates.getSecond().getMonthOfYear());
    assertEquals(30, dates.getSecond().getDayOfMonth());
}