List of usage examples for org.joda.time.format DateTimeFormatter print
public String print(ReadablePartial partial)
From source file:kagoyume.InsertResult.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// ww w . j av a 2 s . com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); int userID = Integer.parseInt(request.getParameter("userID")); String name = request.getParameter("name"); String password = request.getParameter("password"); String mail = request.getParameter("mail"); String address = request.getParameter("address"); DateTime date1 = DateTime.now(); DateTimeFormatter mediumFmt = DateTimeFormat.mediumDate(); String date = mediumFmt.print(date1); try { UserData ud = new UserData(); ud.setUserID(userID); ud.setName(name); ud.setPassword(password); ud.setMail(mail); ud.setAddress(address); ud.setTotal(0); ud.setNewDate(String.valueOf(date1)); } catch (Exception e) { } }
From source file:main.java.miro.validator.stats.export.RPKIRepositoryStatsSerializer.java
License:Open Source License
public JsonElement serialize(RPKIRepositoryStats src, Type typeOfSrc, JsonSerializationContext context) { JsonObject statsObj = new JsonObject(); statsObj.add("name", new JsonPrimitive(src.getName())); DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); String dtStr = fmt.print(src.getTimestamp()); statsObj.add("timestamp", new JsonPrimitive(dtStr)); statsObj.add("trustAnchor", new JsonPrimitive(src.getTrustAnchor())); statsObj.add("result", context.serialize(src.getResult())); return statsObj; }
From source file:me.vertretungsplan.additionalinfo.BaseIcalParser.java
License:Mozilla Public License
@Override public AdditionalInfo getAdditionalInfo() throws IOException { AdditionalInfo info = new AdditionalInfo(); info.setTitle(getTitle());/* ww w. ja va 2 s. co m*/ String rawdata = httpGet(getIcalUrl(), "UTF-8"); if (shouldStripTimezoneInfo()) { Pattern pattern = Pattern.compile("BEGIN:VTIMEZONE.*END:VTIMEZONE", Pattern.DOTALL); rawdata = pattern.matcher(rawdata).replaceAll(""); } DateTime now = DateTime.now().withTimeAtStartOfDay(); List<ICalendar> icals = Biweekly.parse(rawdata).all(); List<Event> events = new ArrayList<>(); for (ICalendar ical : icals) { for (VEvent event : ical.getEvents()) { Event item = new Event(); TimeZone timezoneStart = getTimeZoneStart(ical, event); if (event.getDescription() != null) { item.description = event.getDescription().getValue(); } if (event.getSummary() != null) { item.summary = event.getSummary().getValue(); } if (event.getDateStart() != null) { item.startDate = new DateTime(event.getDateStart().getValue()); item.startHasTime = event.getDateStart().getValue().hasTime(); } else { continue; } if (event.getDateEnd() != null) { item.endDate = new DateTime(event.getDateEnd().getValue()); item.endHasTime = event.getDateEnd().getValue().hasTime(); } if (event.getLocation() != null) { item.location = event.getLocation().getValue(); } if (event.getUrl() != null) { item.url = event.getUrl().getValue(); } if (event.getRecurrenceRule() == null && item.endDate != null && (item.endDate.compareTo(now) < 0)) { continue; } else if (event.getRecurrenceRule() == null && (item.startDate.compareTo(now) < 0)) { continue; } if (event.getRecurrenceRule() != null && event.getRecurrenceRule().getValue().getUntil() != null && event.getRecurrenceRule().getValue().getUntil().compareTo(now.toDate()) < 0) { continue; } if (event.getRecurrenceRule() != null) { Duration duration = null; if (event.getDateEnd() != null) { duration = new Duration(new DateTime(event.getDateStart().getValue()), new DateTime(event.getDateEnd().getValue())); } DateIterator iterator = event.getDateIterator(timezoneStart); while (iterator.hasNext()) { Date date = iterator.next(); Event reccitem = item.clone(); reccitem.startDate = new DateTime(date); reccitem.endDate = reccitem.startDate.plus(duration); if (item.startDate.equals(reccitem.startDate)) continue; if (item.endDate != null && (item.endDate.compareTo(now) < 0)) { continue; } else if (item.endDate == null && (item.startDate.compareTo(now) < 0)) { continue; } events.add(reccitem); } } if (item.endDate != null && (item.endDate.compareTo(now) < 0)) { continue; } else if (item.endDate == null && (item.startDate.compareTo(now) < 0)) { continue; } events.add(item); } } Collections.sort(events, new Comparator<Event>() { @Override public int compare(Event o1, Event o2) { return o1.startDate.compareTo(o2.startDate); } }); StringBuilder content = new StringBuilder(); int count = 0; DateTimeFormatter fmtDt = DateTimeFormat.shortDateTime().withLocale(Locale.GERMANY); DateTimeFormatter fmtD = DateTimeFormat.shortDate().withLocale(Locale.GERMANY); DateTimeFormatter fmtT = DateTimeFormat.shortTime().withLocale(Locale.GERMANY); for (Event item : events) { if (count >= getMaxItemsCount()) { break; } else if (count != 0) { content.append("<br><br>\n\n"); } DateTime start = item.startDate; if (item.endDate != null) { DateTime end = item.endDate; if (!item.endHasTime) { end = end.minusDays(1); } content.append((item.startHasTime ? fmtDt : fmtD).print(start)); if (!end.equals(start)) { content.append(" - "); if (item.startHasTime && item.endHasTime && end.toLocalDate().equals(start.toLocalDate())) { content.append(fmtT.print(end)); } else { content.append((item.endHasTime ? fmtDt : fmtD).print(end)); } } } else { content.append(fmtDt.print(start)); } content.append("<br>\n"); content.append("<b>"); content.append(item.summary); content.append("</b>"); count++; } info.setText(content.toString()); return info; }
From source file:mobi.daytoday.DayToDay.DateWrap.java
License:Apache License
/** * Add the number of days to the date and return the result * /*w w w . ja v a 2s . co m*/ * @param theDate * - date in DATE_FORMAT format * @param numDays * - number of days to add (may be negative for subtraction) * @return result of the addition in DATE_FORMAT format * @throws Exception * - if there is any error */ public static String addToDate(String theDate, int numDays) throws Exception { DateTime date = dtForm.parseDateTime(theDate); Duration days = standardDays(numDays); DateTime result = date.plus(days); DateTimeFormatter MonthDayYearFormat = new DateTimeFormatterBuilder().appendMonthOfYear(1) .appendLiteral('-').appendDayOfMonth(1).appendLiteral('-').appendYear(4, 4).toFormatter(); return MonthDayYearFormat.print(result); }
From source file:monasca.persister.repository.influxdb.Measurement.java
License:Apache License
public String getISOFormattedTimeString() { DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime(); Date date = new Date(this.time); DateTime dateTime = new DateTime(date.getTime(), DateTimeZone.UTC); return dateFormatter.print(dateTime); }
From source file:name.gluino.webmailfeed.ClubMember.java
License:Open Source License
@Override public String toString() { DateTimeFormatter fmttr = DateTimeFormat.forPattern("YYYY-MMMM-dd"); StringBuilder buf = new StringBuilder(); buf.append("First Name : " + firstName + "\n"); buf.append("Last Name : " + lastName + "\n"); for (String e : emailAddressList) { buf.append("Email : " + e + "\n"); }//from w w w. j a v a 2s. c om if (birthday != null) { buf.append("Birthday : " + fmttr.print(birthday) + "\n"); buf.append("Age : " + getAge() + "\n"); } else { buf.append("Birthday : ?\n"); } if (level != null) { buf.append("Level : " + level + "\n"); } else { buf.append("Level : ?\n"); } return buf.toString(); }
From source file:name.martingeisse.admin.application.converter.DateTimeConverter.java
License:Open Source License
@Override public String convertToString(DateTime value, Locale locale) { try {//from w w w . j a v a2 s .c om DateTimeFormatter formatter = getFormatter(locale); return formatter.print(value); } catch (Exception e) { throw new ConversionException(e); } }
From source file:name.martingeisse.admin.application.converter.LocalDateConverter.java
License:Open Source License
@Override public String convertToString(LocalDate value, Locale locale) { try {// www. j ava 2 s.c om DateTimeFormatter formatter = getFormatter(locale); return formatter.print(value); } catch (Exception e) { throw new ConversionException(e); } }
From source file:name.martingeisse.admin.application.converter.LocalDateTimeConverter.java
License:Open Source License
@Override public String convertToString(LocalDateTime value, Locale locale) { try {// w w w .ja va 2 s . c o m DateTimeFormatter formatter = getFormatter(locale); return formatter.print(value); } catch (Exception e) { throw new ConversionException(e); } }
From source file:name.martingeisse.admin.application.converter.LocalTimeConverter.java
License:Open Source License
@Override public String convertToString(LocalTime value, Locale locale) { try {//w ww .j a v a 2 s . c o m DateTimeFormatter formatter = getFormatter(locale); return formatter.print(value); } catch (Exception e) { throw new ConversionException(e); } }