List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:fr.xebia.extras.selma.it.custom.interceptor.beans.CustomDateTimeInterceptor.java
License:Apache License
public void intercept(ValidationJson in, Validation out) { final Integer eventDateStamp = in.getEventDateStamp(); final Integer eventTimeStamp = in.getEventTimeStamp(); if (null != eventDateStamp && null != eventTimeStamp) { final LocalDate date = LocalDate.now().plusDays(eventDateStamp); final LocalTime time = LocalTime.now().plusMinutes(eventTimeStamp); final Calendar validationDate = GregorianCalendar.getInstance(); validationDate.setTime(date.toDate()); validationDate.setTimeZone(TimeZone.getDefault()); out.setValidationDate(validationDate); }/*w w w . j a va 2s .c om*/ }
From source file:io.github.benas.randombeans.randomizers.jodatime.range.JodaTimeLocalDateRangeRandomizer.java
License:Open Source License
/** * Create a new {@link JodaTimeLocalDateRangeRandomizer}. * @param min date/*from ww w . j av a 2 s . c o m*/ * @param max date * @param seed initial seed */ public JodaTimeLocalDateRangeRandomizer(final LocalDate min, final LocalDate max, final long seed) { super(min.toDate(), max.toDate(), seed); }
From source file:io.kahu.hawaii.util.xml.bind.DateTimeConverter.java
License:Apache License
public static String printDate(LocalDate input) { Calendar cal = Calendar.getInstance(); cal.setTime(input.toDate()); return DatatypeConverter.printDate(cal); }
From source file:io.renren.common.utils.DateUtils.java
License:Apache License
/** * ????/* w ww .ja v a2 s. co m*/ * @param week 0-1-212 * @return date[0]?date[1]? */ public static Date[] getWeekStartAndEnd(int week) { DateTime dateTime = new DateTime(); LocalDate date = new LocalDate(dateTime.plusWeeks(week)); date = date.dayOfWeek().withMinimumValue(); Date beginDate = date.toDate(); Date endDate = date.plusDays(6).toDate(); return new Date[] { beginDate, endDate }; }
From source file:net.objectlab.kit.console.ConsoleMenu.java
License:Apache License
public static LocalDate getYMD(final String title, final LocalDate defaultValue) { final Date dateStr = ConsoleMenu.getDate(title, defaultValue != null ? defaultValue.toDateMidnight().toDate() : null); if (dateStr != null) { return new LocalDate(dateStr); }//from w w w .j a va2 s.c o m return null; }
From source file:net.solarnetwork.node.weather.wu.BasicWeatherUndergoundClient.java
License:Open Source License
private GeneralDayDatum parseForecast(final JsonNode node, final int dayOffset) { if (node == null) { return null; }// w w w .j a v a 2 s .c o m GeneralDayDatum datum = new GeneralDayDatum(); JsonNode forecastNode = node.get("simpleforecast"); if (forecastNode == null) { return null; } JsonNode dayArrayNode = forecastNode.get("forecastday"); if (dayArrayNode == null || !dayArrayNode.isArray()) { return null; } JsonNode dayNode = dayArrayNode.get(dayOffset); JsonNode dateNode = dayNode.get("date"); String tz = parseStringAttribute(dateNode, "tz_long"); Long epoch = parseLongAttribute(dateNode, "epoch"); if (tz != null && epoch != null) { LocalDate date = new LocalDate(epoch.longValue() * 1000, DateTimeZone.forID(tz)); datum.setCreated(date.toDate()); } datum.setRain(parseIntegerAttribute(dayNode.get("qpf_allday"), "mm")); datum.setSkyConditions(parseStringAttribute(dayNode, "conditions")); JsonNode snowNode = dayNode.get("snow_allday"); if (snowNode != null) { Integer snowCm = parseIntegerAttribute(snowNode, "cm"); if (snowCm != null) { // convert snow to mm datum.setSnow(snowCm.intValue() * 10); } } JsonNode tempNode = dayNode.get("high"); if (tempNode != null) { datum.setTemperatureMaximum(parseBigDecimalAttribute(tempNode, "celsius")); } tempNode = dayNode.get("low"); if (tempNode != null) { datum.setTemperatureMinimum(parseBigDecimalAttribute(tempNode, "celsius")); } JsonNode windNode = dayNode.get("avewind"); if (windNode != null) { datum.setWindDirection(parseIntegerAttribute(windNode, "degrees")); datum.setWindSpeed(parseWindSpeed(windNode, "kph")); } JsonNode txtNode = node.get("txt_forecast"); if (txtNode != null) { JsonNode txtDayArrayNode = txtNode.get("forecastday"); if (txtDayArrayNode != null && txtDayArrayNode.isArray()) { // txt day nodes come in pairs, one for day one for night; we only get day values JsonNode txtDayNode = txtDayArrayNode.get(dayOffset * 2); if (txtDayNode != null) { // TODO: support imperial description gathering via class property datum.setBriefOverview(parseStringAttribute(txtDayNode, "fcttext_metric")); } } } return datum; }
From source file:nl.surfnet.coin.selfservice.control.StatisticsController.java
License:Apache License
private List<LoginData> getLoginData(String spEntityId, InstitutionIdentityProvider selectedIdp, LocalDate startDate, LocalDate endDate) throws IOException { String statistics;// w w w .ja v a 2s. c o m if (spEntityId == null) { statistics = cruncher.getLoginsByIdp(startDate.toDate(), endDate.toDate(), selectedIdp.getId()); } else { statistics = cruncher.getLoginsByIdpAndSp(startDate.toDate(), endDate.toDate(), selectedIdp.getId(), spEntityId); } return Arrays.asList(new ObjectMapper().readValue(statistics, LoginData[].class)); }
From source file:odin.domain.Sprint.java
License:Apache License
public static int getRemainingAvailability(String sprintString, String username) { EntityManager em = DBUtil.getEntityManager(); TypedQuery<Sprint> q = em//from ww w .j a v a2 s. c o m .createQuery("select s from Sprint s WHERE s.sprintName = :sprintString", Sprint.class) .setParameter("sprintString", sprintString); Sprint sprint = q.getSingleResult(); // em.detach(sprint); LocalDate today = new LocalDate(); int availability = 0; SimpleDateFormat sdf = new SimpleDateFormat("M/d/yy"); for (Week week : sprint.getWeeks()) { LocalDate weekEndDate = LocalDate.fromDateFields(week.getEndDate()); int days = Days.daysBetween(today, weekEndDate).getDays(); System.out.println(days); if (days >= 0) { if (days < 6) { // Calculate hours left on a part week. int remainingHours = Availability.getAvailability(sdf.format(weekEndDate.toDate()), username) / 5 * days; availability = availability + remainingHours; System.out.println("Part week. Calculated availability for week ending " + sdf.format(week.getEndDate()) + " is " + remainingHours); } else availability = availability + Availability.getAvailability(sdf.format(weekEndDate.toDate()), username); } } em.close(); return availability; }
From source file:op.allowance.PnlAllowance.java
License:Open Source License
private CollapsiblePane createCP4(final Resident resident, final int year) { LocalDate min = SYSCalendar.bom(minmax.get(resident).getFirst()); LocalDate max = resident.isActive() ? new LocalDate() : SYSCalendar.eom(minmax.get(resident).getSecond()); final LocalDate start = new LocalDate(year, 1, 1).isBefore(min.dayOfMonth().withMinimumValue()) ? min.dayOfMonth().withMinimumValue() : new LocalDate(year, 1, 1); final LocalDate end = new LocalDate(year, 12, 31).isAfter(max.dayOfMonth().withMaximumValue()) ? max.dayOfMonth().withMaximumValue() : new LocalDate(year, 12, 31); final String key = resident.getRID() + "-" + year; if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try {//ww w. j av a 2 s.c om cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } final CollapsiblePane cpYear = cpMap.get(key); if (!carrySums.containsKey(key + "-12")) { carrySums.put(key + "-12", AllowanceTools.getSUM(resident, SYSCalendar.eoy(start))); } String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"520\" align=\"left\"><font size=+1>" + Integer.toString(year) + "</font></td>" + "<td width=\"200\" align=\"right\">" + (carrySums.get(key + "-12").compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(carrySums.get(key + "-12")) + (carrySums.get(key + "-12").compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpYear.setCollapsed(!cpYear.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); GUITools.addExpandCollapseButtons(cpYear, cptitle.getRight()); /*** * ____ _ _ __ __ * | _ \ _ __(_)_ __ | |\ \ / /__ __ _ _ __ * | |_) | '__| | '_ \| __\ V / _ \/ _` | '__| * | __/| | | | | | | |_ | | __/ (_| | | * |_| |_| |_|_| |_|\__||_|\___|\__,_|_| * */ final JButton btnPrintYear = new JButton(SYSConst.icon22print2); btnPrintYear.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintYear.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintYear.setContentAreaFilled(false); btnPrintYear.setBorder(null); btnPrintYear.setToolTipText(SYSTools.xx("misc.tooltips.btnprintyear")); btnPrintYear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String carry4printKey = resident.getRID() + "-" + (year - 1) + "-12"; if (!carrySums.containsKey(carry4printKey)) { carrySums.put(carry4printKey, AllowanceTools.getSUM(resident, SYSCalendar.eoy(start.minusYears(1)))); } SYSFilesTools.print(AllowanceTools.getAsHTML(AllowanceTools.getYear(resident, start.toDate()), carrySums.get(carry4printKey), resident), true); } }); cptitle.getRight().add(btnPrintYear); cpYear.setTitleLabelComponent(cptitle.getMain()); cpYear.setSlidingDirection(SwingConstants.SOUTH); cpYear.setBackground(SYSConst.orange1[SYSConst.medium3]); cpYear.setOpaque(true); /*** * _ _ _ _ * ___| (_) ___| | _____ __| | ___ _ __ _ _ ___ __ _ _ __ * / __| | |/ __| |/ / _ \/ _` | / _ \| '_ \ | | | |/ _ \/ _` | '__| * | (__| | | (__| < __/ (_| | | (_) | | | | | |_| | __/ (_| | | * \___|_|_|\___|_|\_\___|\__,_| \___/|_| |_| \__, |\___|\__,_|_| * |___/ */ cpYear.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { JPanel pnlContent = new JPanel(new VerticalLayout()); // somebody clicked on the year // monthly informations will be generated. even if there // are no allowances for that month for (LocalDate month = end; month.compareTo(start) >= 0; month = month.minusMonths(1)) { pnlContent.add(createCP4(resident, month)); } cpYear.setContentPane(pnlContent); cpYear.setOpaque(false); } }); cpYear.setBackground(getBG(resident, 9)); if (!cpYear.isCollapsed()) { JPanel pnlContent = new JPanel(new VerticalLayout()); for (LocalDate month = end; month.compareTo(start) > 0; month = month.minusMonths(1)) { pnlContent.add(createCP4(resident, month)); } cpYear.setContentPane(pnlContent); } cpYear.setHorizontalAlignment(SwingConstants.LEADING); cpYear.setOpaque(false); return cpYear; }
From source file:op.allowance.PnlAllowance.java
License:Open Source License
private CollapsiblePane createCP4(final Resident resident, final LocalDate month) { final String key = getKey(resident, month); if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try {/* ww w . j a va 2 s . c o m*/ cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } final CollapsiblePane cpMonth = cpMap.get(key); if (!carrySums.containsKey(key)) { carrySums.put(key, AllowanceTools.getSUM(resident, SYSCalendar.eom(month))); } String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"520\" align=\"left\">" + monthFormatter.format(month.toDate()) + "</td>" + "<td width=\"200\" align=\"right\">" + (carrySums.get(key).compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "") + cf.format(carrySums.get(key)) + (carrySums.get(key).compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>" + "</table>" + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpMonth.setCollapsed(!cpMonth.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); /*** * ____ _ _ __ __ _ _ * | _ \ _ __(_)_ __ | |_| \/ | ___ _ __ | |_| |__ * | |_) | '__| | '_ \| __| |\/| |/ _ \| '_ \| __| '_ \ * | __/| | | | | | | |_| | | | (_) | | | | |_| | | | * |_| |_| |_|_| |_|\__|_| |_|\___/|_| |_|\__|_| |_| * */ final JButton btnPrintMonth = new JButton(SYSConst.icon22print2); btnPrintMonth.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintMonth.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintMonth.setContentAreaFilled(false); btnPrintMonth.setBorder(null); btnPrintMonth.setToolTipText(SYSTools.xx("misc.tooltips.btnprintmonth")); btnPrintMonth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!cashmap.containsKey(key)) { cashmap.put(key, AllowanceTools.getMonth(resident, month.toDate())); } final BigDecimal carry4print = AllowanceTools.getSUM(resident, SYSCalendar.eom(month.minusMonths(1))); SYSFilesTools.print(AllowanceTools.getAsHTML(cashmap.get(key), carry4print, resident), true); } }); cptitle.getRight().add(btnPrintMonth); cpMonth.setTitleLabelComponent(cptitle.getMain()); cpMonth.setSlidingDirection(SwingConstants.SOUTH); cpMonth.setBackground(getBG(resident, 10)); /*** * _ _ _ _ _ _ * ___| (_) ___| | _____ __| | ___ _ __ _ __ ___ ___ _ __ | |_| |__ * / __| | |/ __| |/ / _ \/ _` | / _ \| '_ \ | '_ ` _ \ / _ \| '_ \| __| '_ \ * | (__| | | (__| < __/ (_| | | (_) | | | | | | | | | | (_) | | | | |_| | | | * \___|_|_|\___|_|\_\___|\__,_| \___/|_| |_| |_| |_| |_|\___/|_| |_|\__|_| |_| * */ cpMonth.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpMonth.setContentPane(createContentPanel4(resident, month)); cpMonth.setOpaque(false); } }); if (!cpMonth.isCollapsed()) { cpMonth.setContentPane(createContentPanel4(resident, month)); } cpMonth.setHorizontalAlignment(SwingConstants.LEADING); cpMonth.setOpaque(false); return cpMonth; }