List of usage examples for org.joda.time LocalDate LocalDate
public LocalDate(int year, int monthOfYear, int dayOfMonth)
ISOChronology
. From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.GanttItemWrapper.java
License:Open Source License
void calculateDatesByChildTasks() { if (CollectionUtils.isNotEmpty(subItems)) { LocalDate calStartDate = new LocalDate(2100, 1, 1); LocalDate calEndDate = new LocalDate(1970, 1, 1); for (GanttItemWrapper item : subItems) { calStartDate = DateTimeUtils.min(calStartDate, item.getStartDate()); calEndDate = DateTimeUtils.max(calEndDate, item.getEndDate()); }//from w ww.ja va 2 s. c o m fixedStartDateByChilds = calStartDate; fixedEndDatebyChilds = calEndDate; setStartAndEndDate(calStartDate, calEndDate, true, true); } }
From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserCustomizeReportOutputWindow.java
License:Open Source License
@Override protected Object[] buildSampleData() { return new Object[] { "John Adams", "Administrator", "john.adam@mycollab.com", AppContext.formatDate(new LocalDate(1979, 3, 13).toDate()), "11111111", "11111111", "MyCollab" }; }
From source file:com.excilys.sugadroid.services.SugarBeanFactoryImpl.java
License:Open Source License
private Object getSetterParameter(Method m, String value) throws Exception { Class<?>[] params = m.getParameterTypes(); if (params.length != 1) { throw new Exception("The setter should have only one parameter"); }/*from w ww. j a v a 2 s . co m*/ Class<?> parameterClass = params[0]; if (parameterClass.equals(String.class)) { return value; } else if (parameterClass.equals(LocalDate.class)) { StringTokenizer stk = new StringTokenizer(value, "-"); int year = Integer.parseInt(stk.nextToken()); int month = Integer.parseInt(stk.nextToken()); int day = Integer.parseInt(stk.nextToken()); return new LocalDate(year, month, day); } else if (parameterClass.equals(LocalTime.class)) { StringTokenizer stk = new StringTokenizer(value, ":"); int hour = Integer.parseInt(stk.nextToken()); int minutes = Integer.parseInt(stk.nextToken()); return new LocalTime(hour, minutes); } else if (parameterClass.equals(Integer.class)) { return new Integer(value); } else if (parameterClass.equals(LocalDateTime.class)) { StringTokenizer stk = new StringTokenizer(value, " "); String date = stk.nextToken(); String time = stk.nextToken(); stk = new StringTokenizer(date, "-"); int year = Integer.parseInt(stk.nextToken()); int month = Integer.parseInt(stk.nextToken()); int day = Integer.parseInt(stk.nextToken()); stk = new StringTokenizer(time, ":"); int hour = Integer.parseInt(stk.nextToken()); int minutes = Integer.parseInt(stk.nextToken()); return new LocalDateTime(year, month, day, hour, minutes); } throw new Exception("Unknown type: " + parameterClass.getSimpleName()); }
From source file:com.github.fauu.natrank.service.CountryServiceImpl.java
License:Open Source License
@Override @Transactional//from w ww. j a va2 s. co m public void addFlags(List<CountryWithFlagEntryYears> countriesWithFlagEntryYears) throws DataAccessException { for (CountryWithFlagEntryYears countryWithFlagEntryYears : countriesWithFlagEntryYears) { if (Strings.isNullOrEmpty(countryWithFlagEntryYears.getFlagEntryYears())) { continue; } Country country = countryWithFlagEntryYears.getCountry(); String[] entryYears = countryWithFlagEntryYears.getFlagEntryYears().split(";"); for (String entryYearStr : entryYears) { int entryYear = Integer.parseInt(entryYearStr); Flag newFlag = new Flag(); newFlag.setCode(country.getCode() + entryYearStr); newFlag.setCountry(country); Period flagPeriod = new Period(); flagPeriod.setFromDate(new LocalDate(entryYear, 1, 1)); newFlag.setPeriod(flagPeriod); Flag latestFlag = country.getLastFlag(); latestFlag.getPeriod().setToDate(flagPeriod.getFromDate().minusDays(1)); country.getFlags().add(newFlag); } countryRepository.save(country); } }
From source file:com.github.fauu.natrank.service.MatchServiceImpl.java
License:Open Source License
@Override public Page<Match> findByYear(int year, Pageable pageable) throws DataAccessException { return matchRepository.findByDateBetween(new LocalDate(year, 1, 1), new LocalDate(year, 12, 31), pageable); }
From source file:com.github.fauu.natrank.util.PeriodUtils.java
License:Open Source License
public static Period createFromString(String periodStr) { Period period = new Period(); // TODO: Perhaps refactor this to use regex (and also some proper error checking) if (periodStr.length() == 11) { boolean rightBounded = false; if (periodStr.charAt(0) == '-') { periodStr = periodStr.substring(1, 11); rightBounded = true;// www .j av a2 s . co m } else if (periodStr.charAt(10) == '-') { periodStr = periodStr.substring(0, 10); } else { return null; } String[] periodStrParts = periodStr.split("-"); LocalDate date = new LocalDate(Integer.parseInt(periodStrParts[0]), Integer.parseInt(periodStrParts[1]), Integer.parseInt(periodStrParts[2])); if (rightBounded) { period.setToDate(date); } else { period.setFromDate(date); } } else if (periodStr.length() == 21) { // FIXME: DRY! String[] periodStrParts = periodStr.split("-"); LocalDate fromDate = new LocalDate(Integer.parseInt(periodStrParts[0]), Integer.parseInt(periodStrParts[1]), Integer.parseInt(periodStrParts[2])); LocalDate toDate = new LocalDate(Integer.parseInt(periodStrParts[3]), Integer.parseInt(periodStrParts[4]), Integer.parseInt(periodStrParts[5])); period.setFromDate(fromDate); period.setToDate(toDate); } else { return null; } return period; }
From source file:com.google.ical.compat.jodatime.LocalDateIteratorFactory.java
License:Apache License
static LocalDate dateValueToLocalDate(DateValue dvUtc) { return new LocalDate(dvUtc.year(), dvUtc.month(), dvUtc.day()); }
From source file:com.google.walkaround.wave.server.googleimport.DaysSinceEpoch.java
License:Open Source License
public static long fromYMD(int y, int m, int d) { // Go through a LocalDate in the unverified hope that it will do // something smart about out-of-range arguments. return fromLocalDate(new LocalDate(y, m, d)); }
From source file:com.gst.integrationtests.common.loans.LoanTransactionHelper.java
License:Apache License
public void checkAccrualTransactionForRepayment(final LocalDate transactionDate, final Float interestPortion, final Float feePortion, final Float penaltyPortion, final Integer loanID) { ArrayList<HashMap> transactions = (ArrayList<HashMap>) getLoanDetail(this.requestSpec, this.responseSpec, loanID, "transactions"); boolean isTransactionFound = false; for (int i = 0; i < transactions.size(); i++) { HashMap transactionType = (HashMap) transactions.get(i).get("type"); boolean isAccrualTransaction = (Boolean) transactionType.get("accrual"); if (isAccrualTransaction) { ArrayList<Integer> accrualEntryDateAsArray = (ArrayList<Integer>) transactions.get(i).get("date"); LocalDate accrualEntryDate = new LocalDate(accrualEntryDateAsArray.get(0), accrualEntryDateAsArray.get(1), accrualEntryDateAsArray.get(2)); if (transactionDate.equals(accrualEntryDate)) { isTransactionFound = true; assertEquals("Mismatch in transaction amounts", interestPortion, Float.valueOf(String.valueOf(transactions.get(i).get("interestPortion")))); assertEquals("Mismatch in transaction amounts", feePortion, Float.valueOf(String.valueOf(transactions.get(i).get("feeChargesPortion")))); assertEquals("Mismatch in transaction amounts", penaltyPortion, Float.valueOf(String.valueOf(transactions.get(i).get("penaltyChargesPortion")))); break; }//from www. j a v a2 s.c om } } assertTrue("No Accrual entries are posted", isTransactionFound); }
From source file:com.hendi.cekusia.Joda.java
public static void main(String[] args) { LocalDate birthdate = new LocalDate(1986, 9, 19); //Birth date LocalDate now = new LocalDate(); //Today's date Period period = new Period(birthdate, now, PeriodType.yearMonthDay()); //Now access the values as below System.out.println("Using Joda Time"); System.out.println("Usia : " + period.getYears() + " Tahun " + period.getMonths() + " Bulan " + period.getDays() + " Hari "); System.out.println();/*from w w w .j a v a 2s.co m*/ }