List of usage examples for org.apache.commons.lang3.time DateFormatUtils format
public static String format(final Calendar calendar, final String pattern)
Formats a calendar into a specific pattern.
From source file:com.daphne.es.personal.calendar.web.controller.CalendarController.java
@RequestMapping(value = "/new", method = RequestMethod.GET) public String showNewForm( @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat) Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat) Date end, Model model) {//from ww w .ja va 2s . com setColorList(model); Calendar calendar = new Calendar(); calendar.setLength(1); if (start != null) { calendar.setStartDate(start); calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis)); if (DateUtils.isSameDay(start, end)) { calendar.setLength(1); } if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) { calendar.setStartTime(start); } if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) { calendar.setEndTime(end); } } model.addAttribute("model", calendar); return viewName("newForm"); }
From source file:mase.stat.RunTimeStat.java
private void writeStats(EvolutionState state) { long timeSoFar = System.currentTimeMillis() - runStartTime; Date cur = new Date(); state.output.println(state.generation + " " + DurationFormatUtils.formatDurationHMS(timeSoFar) + " " + DateFormatUtils.format(cur, "dd.MM.yy-HH:mm:ss") + " " + totalGenTime + " " + totalEvalTime + " " + evalTime + " " + postEvalTime + " " + preBreedingExchTime + " " + breedingTime + " " + postBreedingExchTime, log); }
From source file:com.framework.demo.web.controller.calendar.CalendarController.java
@RequestMapping(value = "/new", method = RequestMethod.GET) public String showNewForm( @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = dataFormat) Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = dataFormat) Date end, Model model) {/*from w ww . java2 s . c o m*/ setColorList(model); PersonalCalendar calendar = new PersonalCalendar(); calendar.setLength(1); if (start != null) { calendar.setStartDate(start); calendar.setLength((int) Math.ceil(1.0 * (end.getTime() - start.getTime()) / oneDayMillis)); if (DateUtils.isSameDay(start, end)) { calendar.setLength(1); } if (!"00:00:00".equals(DateFormatUtils.format(start, "HH:mm:ss"))) { calendar.setStartTime(start); } if (!"00:00:00".equals(DateFormatUtils.format(end, "HH:mm:ss"))) { calendar.setEndTime(end); } } model.addAttribute("model", calendar); return viewName("newForm"); }
From source file:com.chenxin.authority.common.logback.DBAppender.java
void bindLoggingEventWithInsertStatement(PreparedStatement stmt, ILoggingEvent event) throws SQLException { stmt.setString(TIMESTMP_INDEX,//from w w w.j a v a 2 s. com DateFormatUtils.format(new Date(event.getTimeStamp()), "yyyy-MM-dd HH:mm:ss")); stmt.setString(FORMATTED_MESSAGE_INDEX, event.getFormattedMessage()); stmt.setString(LOGGER_NAME_INDEX, event.getLoggerName()); stmt.setString(LEVEL_STRING_INDEX, event.getLevel().toString()); stmt.setString(THREAD_NAME_INDEX, event.getThreadName()); stmt.setShort(REFERENCE_FLAG_INDEX, DBHelper.computeReferenceMask(event)); }
From source file:eu.europa.ec.fisheries.uvms.reporting.service.dto.MovementDTO.java
public SimpleFeature toFeature() throws ReportingServiceException, ParseException { SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(SIMPLE_FEATURE_TYPE); featureBuilder.set(GEOMETRY, GeometryUtil.toGeometry(getWkt())); featureBuilder.set(POSITION_TIME,/*from www .j a va 2 s . c o m*/ getPositionTime() != null ? DateFormatUtils.format(getPositionTime(), DateUtils.DATE_TIME_UI_FORMAT) : null); featureBuilder.set(CONNECTION_ID, getConnectId()); featureBuilder.set(STATUS, getStatus()); featureBuilder.set(REPORTED_COURSE, getReportedCourse()); featureBuilder.set(MOVEMENT_GUID, getGuid()); if (getMovementType() != null) { featureBuilder.set(MOVEMENT_TYPE, getMovementType().value()); } if (getActivity() != null && getActivity().getMessageType() != null) { featureBuilder.set(ACTIVITY_TYPE, movementType.getActivity().getMessageType().value()); } featureBuilder.set(REPORTED_SPEED, velocityConverter.convert(getReportedSpeed() != null ? getReportedSpeed() : 0)); featureBuilder.set(CALCULATED_SPEED, velocityConverter.convert(getCalculatedSpeed() != null ? getCalculatedSpeed() : 0)); featureBuilder.set(CFR, asset.getCfr()); featureBuilder.set(COUNTRY_CODE, asset.getCountryCode()); featureBuilder.set(IRCS, asset.getIrcs()); featureBuilder.set(NAME, asset.getName()); featureBuilder.set(EXTERNAL_MARKING, asset.getExternalMarking()); featureBuilder.set(SOURCE, getSource()); return featureBuilder.buildFeature(getGuid()); }
From source file:ch.tkuhn.nanobrowser.NanopubElement.java
public String getCreateDateString() { if (nanopub == null) return null; Calendar c = nanopub.getCreationTime(); if (c == null) return null; return DateFormatUtils.format(c, DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern()); }
From source file:eu.europa.ec.fisheries.uvms.reporting.service.dto.ActivityDTO.java
public SimpleFeature toFeature() throws ParseException { SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(ACTIVITY); featureBuilder.set(GEOMETRY, GeometryUtil.toGeometry(summary.getGeometry())); featureBuilder.set(ACTIVITY_TYPE, summary.getActivityType()); featureBuilder.set(ACTIVITY_ID, summary.getActivityId()); featureBuilder.set(VESSEL_GUID, summary.getVesselGuid()); featureBuilder.set(TRIPID, summary.getTripId()); featureBuilder.set(FLAG_STATE, summary.getFlagState()); featureBuilder.set(IS_CORRECTION, summary.isCorrection()); featureBuilder.set(ACCEPTED_DATE_TIME, summary.getAcceptedDateTime() != null ? DateFormatUtils.format(summary.getAcceptedDateTime().toGregorianCalendar(), DateUtils.DATE_TIME_UI_FORMAT) : null);//from w w w.j av a 2s.com featureBuilder.set(DATA_SOURCE, summary.getDataSource()); featureBuilder.set(REPORT_TYPE, summary.getReportType()); featureBuilder.set(PURPOSE_CODE, summary.getPurposeCode()); featureBuilder.set(VESSEL_NAME, summary.getVesselName()); featureBuilder.set(GEARS, summary.getGears()); featureBuilder.set(SPECIES, summary.getSpecies()); featureBuilder.set(PORTS, summary.getPorts()); featureBuilder.set(AREAS, summary.getAreas()); List<VesselIdentifierType> vesselIdentifiers = summary.getVesselIdentifiers(); if (!CollectionUtils.isEmpty(vesselIdentifiers)) { for (VesselIdentifierType vesselIdentifierType : vesselIdentifiers) { if (!StringUtils.isEmpty(vesselIdentifierType.getValue())) { featureBuilder.set(vesselIdentifierType.getKey().toString(), vesselIdentifierType.getValue()); } } } return featureBuilder.buildFeature(null); }
From source file:cn.mypandora.util.MyDateUtils.java
/** * ?//from ww w.j a v a 2 s .c o m * * @return */ public static String getNextMonthEnd() { Calendar cal = Calendar.getInstance(); // cal.set(Calendar.DATE, +1); // cal.add(Calendar.MONTH, +2); // cal.add(Calendar.DATE, -1); // return DateFormatUtils.format(cal, DATE_FORMAT); // cal.add(Calendar.MONTH, 1);// cal.set(Calendar.DATE, 1);// cal.roll(Calendar.DATE, -1);// ? return DateFormatUtils.format(cal, DATE_FORMAT); }
From source file:com.norconex.committer.core.impl.FileSystemCommitter.java
private synchronized File createFile(String suffix) throws IOException { // Create date directory File dateDir = new File(directory, DateFormatUtils.format(System.currentTimeMillis(), "yyyy/MM-dd/hh/mm/ss")); if (!dateDir.exists()) { try {/*from www . ja v a 2 s . c o m*/ FileUtils.forceMkdir(dateDir); } catch (IOException e) { throw new CommitterException("Cannot create commit directory: " + dateDir, e); } } // Create file return new File(dateDir, TimeIdGenerator.next() + suffix); }
From source file:com.omertron.slackbot.SlackBot.java
/** * Send a start up message to all BOT admins to inform them of the bot's * restart//ww w . ja v a 2s. c o m * * @param session */ private static void notifyStartup(SlackSession session) { String message = String.format("%1$s started at %2$s", Constants.BOT_NAME, DateFormatUtils.format(new Date(), "dd-MM-yyyy HH:mm:ss")); messageAdmins(session, message); }