List of usage examples for org.joda.time LocalDateTime now
public static LocalDateTime now()
ISOChronology
in the default time zone. From source file:me.tongfei.progressbar.ProgressThread.java
License:Apache License
void refresh() { consoleStream.print('\r'); LocalDateTime currTime = LocalDateTime.now(); Duration elapsed = new Duration(progress.startTime.toDateTime(DateTimeZone.UTC), currTime.toDateTime(DateTimeZone.UTC)); String prefix = progress.task + " " + percentage() + " " + style.leftBracket; int maxSuffixLength = Math.max(0, consoleWidth - consoleRightMargin - prefix.length() - 10); String suffix = style.rightBracket + " " + ratio() + " (" + Util.formatDuration(elapsed) + " / " + eta(elapsed) + ") " + progress.extraMessage; if (suffix.length() > maxSuffixLength) suffix = suffix.substring(0, maxSuffixLength); length = consoleWidth - consoleRightMargin - prefix.length() - suffix.length(); StringBuilder sb = new StringBuilder(); sb.append(prefix);//from ww w .j a v a2s. co m // case of indefinite progress bars if (progress.indefinite) { int pos = (int) (progress.current % length); sb.append(Util.repeat(style.space, pos)); sb.append(style.block); sb.append(Util.repeat(style.space, length - pos - 1)); } // case of definite progress bars else { sb.append(Util.repeat(style.block, progressIntegralPart())); if (progress.current < progress.max) { sb.append(style.fractionSymbols.charAt(progressFractionalPart())); sb.append(Util.repeat(style.space, length - progressIntegralPart() - 1)); } } sb.append(suffix); String line = sb.toString(); consoleStream.print(line); }
From source file:net.rrm.ehour.report.reports.element.AssignmentAggregateReportElement.java
License:Open Source License
/** * Get the progress (booked hours) in percentage of the allotted hours, leaving out the overrun * or for date ranges use the current date vs start & end date (if they're both null) *//*from w ww. ja v a2 s .co m*/ public Optional<Float> getProgressPercentage() { Optional<Float> percentage = Optional.absent(); if (projectAssignment == null) { return Optional.absent(); } if (projectAssignment.getAssignmentType().isAllottedType()) { if (hours != null && projectAssignment.getAllottedHours() != null && hours.floatValue() > 0 && projectAssignment.getAllottedHours() > 0) { percentage = Optional.of((hours.floatValue() / projectAssignment.getAllottedHours()) * 100); } } else if (projectAssignment.getAssignmentType().isDateType() && projectAssignment.getDateStart() != null && projectAssignment.getDateEnd() != null) { LocalDateTime now = LocalDateTime.now(); LocalDateTime start = new LocalDateTime(projectAssignment.getDateStart()); LocalDateTime end = new LocalDateTime(projectAssignment.getDateEnd()); if (now.isBefore(start)) { percentage = Optional.of(0f); } else if (now.isAfter(end)) { percentage = Optional.of(100f); } else { float totalRange = Days.daysBetween(start, end).getDays(); float daysConsumed = Days.daysBetween(start, now).getDays(); percentage = Optional.of((daysConsumed / totalRange) * 100); } // if percentage is above 100 for daterange the user can't book anymore hours // so don't display more than 100% if (percentage.get() > 100) { percentage = Optional.of(100f); } } return percentage; }
From source file:org.apache.fineract.integrationtests.common.organisation.CampaignsHelper.java
License:Apache License
public String getCreateCampaignJSON(String reportName, Integer triggerType) { final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> paramValueMap = new HashMap<>(); Long reportId = getSelectedReportId(reportName); map.put("providerId", 1); map.put("triggerType", triggerType); if (2 == triggerType) { map.put("recurrenceStartDate", LocalDateTime.now().toString(DATE_TIME_FORMAT)); map.put("frequency", 1); map.put("interval", "1"); }/* w w w .j a v a 2s. co m*/ map.put("campaignName", Utils.randomNameGenerator("Campaign_Name_", 5)); map.put("campaignType", 1); map.put("message", "Hi, this is from integtration tests runner"); map.put("locale", "en"); map.put("dateFormat", DATE_FORMAT); map.put("dateTimeFormat", DATE_TIME_FORMAT); map.put("runReportId", reportId); paramValueMap.put("officeId", "1"); paramValueMap.put("loanOfficerId", "1"); paramValueMap.put("reportName", reportName); map.put("paramValue", paramValueMap); String json = new Gson().toJson(map); System.out.println(json); return json; }
From source file:org.apache.fineract.integrationtests.common.organisation.CampaignsHelper.java
License:Apache License
public String getUpdateCampaignJSON(String reportName, Integer triggerType) { final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> paramValueMap = new HashMap<>(); Long reportId = getSelectedReportId(reportName); map.put("providerId", 1); map.put("triggerType", triggerType); if (2 == triggerType) { map.put("recurrenceStartDate", LocalDateTime.now().toString(DATE_TIME_FORMAT)); }// w ww . j a va 2 s . c o m map.put("campaignName", Utils.randomNameGenerator("Campaign_Name_", 5)); map.put("campaignType", 1); map.put("message", "Hi, this is from integtration tests runner"); map.put("locale", "en"); map.put("dateFormat", DATE_FORMAT); map.put("dateTimeFormat", DATE_TIME_FORMAT); map.put("runReportId", reportId); paramValueMap.put("officeId", "1"); paramValueMap.put("loanOfficerId", "1"); paramValueMap.put("reportName", reportName); map.put("paramValue", paramValueMap); String json = new Gson().toJson(map); System.out.println(json); return json; }
From source file:org.apache.flume.formatter.output.RollTimePathManager.java
License:Apache License
@Override public File nextFile() { StringBuilder sb = new StringBuilder(); String date = formatter.print(LocalDateTime.now()); if (!date.equals(lastRoll)) { getFileIndex().set(0);//from ww w. ja v a2 s.c o m lastRoll = date; } sb.append(getPrefix()).append(date).append("-"); sb.append(getFileIndex().incrementAndGet()); if (getExtension().length() > 0) { sb.append(".").append(getExtension()); } currentFile = new File(getBaseDirectory(), sb.toString()); return currentFile; }
From source file:org.apache.isis.core.runtime.services.i18n.po.PoWriter.java
License:Apache License
/** * As per <a href="http://pology.nedohodnik.net/doc/user/en_US/ch-poformat.html">section 2.6</a>. */// w w w . j a v a 2 s .c o m protected void header(final StringBuilder buf) { final String createdAt = LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss+Z"); buf.append("#, fuzzy").append("\n"); buf.append("msgid \"\"").append("\n"); buf.append("msgstr \"\"").append("\n"); buf.append("\"Project-Id-Version: \\n\"").append("\n"); buf.append("\"POT-Creation-Date: ").append(createdAt).append("\\n\"").append("\n"); buf.append("\"MIME-Version: 1.0\\n\"").append("\n"); buf.append("\"Content-Type: text/plain; charset=UTF-8\\n\"").append("\n"); buf.append("\"Content-Transfer-Encoding: 8bit\\n\"").append("\n"); buf.append("\"Plural-Forms: nplurals=2; plural=n != 1;\\n\"").append("\n"); buf.append("\n\n"); }
From source file:org.apache.openejb.arquillian.tests.jaxws.LoadJodaFromTheWebAppResource.java
License:Apache License
@GET public String worked() { LocalDateTime.now().toString(); // just trigger loading if not already done during scanning return LocalDateTime.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); }
From source file:org.cowboyprogrammer.org.OrgTimestamp.java
License:Open Source License
/** * Move this timestamp one repetition.//from w w w .j a v a 2s .c o m */ public void toNextRepeat() { if (repeater != null) { if (repeater.startsWith("++")) { final LocalDateTime now = LocalDateTime.now(); if (now.isAfter(date)) { // Just get it into the future while (now.isAfter(date)) { date = date.plus(repeatPeriod); } } else { // Already in future, just jump date = date.plus(repeatPeriod); } } else if (repeater.startsWith(".+")) { // Count from NOW date = LocalDateTime.now().plus(repeatPeriod); } else { // + date = date.plus(repeatPeriod); } } }
From source file:org.cowboyprogrammer.org.OrgTimestamp.java
License:Open Source License
/** * Return the next repetition of this time, even if * it is already in the future. Null if no repeat. */// w w w. j a v a2 s .c om public LocalDateTime getNextRepetition() { if (repeater == null) return null; final LocalDateTime now = LocalDateTime.now(); LocalDateTime next = date.withDayOfMonth(date.getDayOfMonth()); if (repeater.startsWith("++")) { if (now.isAfter(next)) { // Just get it into the future while (now.isAfter(next)) { next = next.plus(repeatPeriod); } } else { // Already in future, just jump next = next.plus(repeatPeriod); } } else if (repeater.startsWith(".+")) { // Count from NOW next = now.plus(repeatPeriod); } else { // + or next = next.plus(repeatPeriod); } return next; }
From source file:org.cowboyprogrammer.org.OrgTimestamp.java
License:Open Source License
/** * Returns null if no repeater is set. Otherwise the next repetition of this * time which is in the future. If it is already in the future, it will * return that./* w ww . j ava 2 s . c o m*/ */ public LocalDateTime getNextFutureRepetition() { if (repeater == null) { return null; } final LocalDateTime now = LocalDateTime.now(); if (now.isBefore(date)) { // Already in future return date; } // In this case, + and ++ have the same behaviour if (repeater.startsWith("+")) { LocalDateTime next = date.plus(repeatPeriod); // Just get it into the future while (now.isAfter(next)) { next = next.plus(repeatPeriod); } return next; } else { // Count from NOW return now.plus(repeatPeriod); } }