List of usage examples for java.util Date getDate
@Deprecated public int getDate()
From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java
/** * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment} * * @param dateBoxInitDate/*from w w w. j ava 2s.c o m*/ * @param hourCost */ private void bindDateboxInitDate(final Datebox dateBoxInitDate, final ResourcesCostCategoryAssignment assignment) { Util.bind(dateBoxInitDate, new Util.Getter<Date>() { @Override public Date get() { LocalDate dateTime = assignment.getInitDate(); if (dateTime != null) { return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth()); } return null; } }, new Util.Setter<Date>() { @Override public void set(Date value) { if (value != null) { assignment.setInitDate( new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate())); } else { assignment.setInitDate(null); } } }); }
From source file:org.kuali.kpme.core.workarea.validation.WorkAreaMaintenanceDocumentRule.java
protected boolean validateRoleMembers(WorkAreaBo wa, List<? extends PrincipalRoleMemberBo> principalRoleMembers, List<? extends PositionRoleMemberBo> positionRoleMembers, LocalDate effectiveDate, String principalPrefix, String positionPrefix) { boolean valid = true; boolean activeRoleMember = false; Date efftDt = wa.getEffectiveDate(); Timestamp efftTs = new Timestamp(efftDt.getYear(), efftDt.getMonth(), efftDt.getDate(), 0, 0, 0, 0); for (ListIterator<? extends KPMERoleMemberBo> iterator = principalRoleMembers.listIterator(); iterator .hasNext();) {// w w w .j a va 2 s .c om int index = iterator.nextIndex(); KPMERoleMemberBo roleMember = iterator.next(); activeRoleMember |= roleMember.isActive(efftTs); } for (ListIterator<? extends KPMERoleMemberBo> iterator = positionRoleMembers.listIterator(); iterator .hasNext();) { int index = iterator.nextIndex(); KPMERoleMemberBo roleMember = iterator.next(); activeRoleMember |= roleMember.isActive(efftTs); valid &= validateRoleMember(roleMember, effectiveDate, positionPrefix, index); } if (!activeRoleMember) { this.putGlobalError("role.required"); valid = false; } return valid; }
From source file:org.sakaiproject.myshowcase.tool.MyShowcaseRenderThemeDefault.java
private String renderDefaultDate(Date date) { StringBuffer textToInsert = new StringBuffer(); textToInsert.append("<div class=\"date\">"); textToInsert.append("<p><strong>" + myshowcaseService.ordinalOfInteger(date.getDate()) + "</strong> " + myshowcaseService.shortMonthName(date.getMonth()) + "</p>"); textToInsert.append("</div>"); return textToInsert.toString(); }
From source file:org.springframework.extensions.webscripts.json.JSONUtils.java
/** * Convert value to JSON string// w w w . j a v a2s.c om * * @param value Java object value * @param writer JSONWriter for output stream * @throws IOException */ private void valueToJSONString(Object value, JSONWriter writer) throws IOException { if (value instanceof IdScriptableObject && TYPE_DATE.equals(((IdScriptableObject) value).getClassName())) { Date date = (Date) Context.jsToJava(value, Date.class); // Build the JSON object to represent the UTC date writer.startObject().writeValue("zone", "UTC").writeValue("year", date.getYear()) .writeValue("month", date.getMonth()).writeValue("date", date.getDate()) .writeValue("hours", date.getHours()).writeValue("minutes", date.getMinutes()) .writeValue("seconds", date.getSeconds()).writeValue("milliseconds", date.getTime()) .endObject(); } else if (value instanceof NativeJavaObject) { // extract the underlying Java object and recursively output Object javaValue = Context.jsToJava(value, Object.class); valueToJSONString(javaValue, writer); } else if (value instanceof NativeArray) { // Output the native object nativeArrayToJSONString((NativeArray) value, writer); } else if (value instanceof NativeObject) { // Output the native array nativeObjectToJSONString((NativeObject) value, writer); } else if (value instanceof Number) { if (value instanceof Integer || value instanceof Long) { writer.writeValue(((Number) value).longValue()); } else if (value instanceof Double) { writer.writeValue(((Number) value).doubleValue()); } else if (value instanceof Float) { writer.writeValue(((Number) value).floatValue()); } else { writer.writeValue(((Number) value).doubleValue()); } } else if (value instanceof Boolean) { writer.writeValue(((Boolean) value).booleanValue()); } else if (value instanceof Map) { writer.startObject(); for (Object key : ((Map) value).keySet()) { writer.startValue(key.toString()); valueToJSONString(((Map) value).get(key), writer); writer.endValue(); } writer.endObject(); } else if (value instanceof List) { writer.startArray(); for (Object val : (List) value) { valueToJSONString(val, writer); } writer.endArray(); } else if (value != null) { writer.writeValue(value.toString()); } else { writer.writeNullValue(); } }
From source file:org.apache.carbondata.processing.merger.CarbonDataMergerUtil.java
/** * Method to check if the load dates are complied to the configured dates. * * @param segDate1//from w w w .java 2 s .c o m * @param segDate2 * @return */ private static boolean isTwoDatesPresentInRequiredRange(Date segDate1, Date segDate2, long numberOfDaysAllowedToMerge) { if (segDate1 == null || segDate2 == null) { return false; } // take 1 st date add the configured days . Calendar cal1 = Calendar.getInstance(); cal1.set(segDate1.getYear(), segDate1.getMonth(), segDate1.getDate()); Calendar cal2 = Calendar.getInstance(); cal2.set(segDate2.getYear(), segDate2.getMonth(), segDate2.getDate()); long diff = cal2.getTimeInMillis() - cal1.getTimeInMillis(); if ((diff / (24 * 60 * 60 * 1000)) < numberOfDaysAllowedToMerge) { return true; } return false; }
From source file:eionet.util.Util.java
/** * A method for calculating and formatting the current date and time into a String for a log. *///from w w w . jav a 2 s . c o m public static String logTime() { Date date = new Date(); String month = String.valueOf(date.getMonth()); month = (month.length() < 2) ? ("0" + month) : month; String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; String hours = String.valueOf(date.getHours()); hours = (hours.length() < 2) ? ("0" + hours) : hours; String minutes = String.valueOf(date.getMinutes()); minutes = (minutes.length() < 2) ? ("0" + minutes) : minutes; String seconds = String.valueOf(date.getSeconds()); seconds = (seconds.length() < 2) ? ("0" + seconds) : seconds; String time = "[" + month; time = time + "/" + day; time = time + " " + hours; time = time + ":" + minutes; time = time + ":" + seconds; time = time + "] "; return time; }
From source file:com.eryansky.common.utils.StringUtils.java
/** * ???/*w w w. j ava 2 s. c om*/ * * @param time * @return */ @SuppressWarnings("deprecation") public static String processTime(Long time) { long oneDay = 24 * 60 * 60 * 1000; Date now = new Date(); Date orginalTime = new Date(time); long nowDay = now.getTime() - (now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()) * 1000; long yesterday = nowDay - oneDay; String nowHourAndMinute = toDoubleDigit(orginalTime.getHours()) + ":" + toDoubleDigit(orginalTime.getMinutes()); if (time >= now.getTime()) { return ""; } else if ((now.getTime() - time) < (60 * 1000)) { return (now.getTime() - time) / 1000 + "? " + nowHourAndMinute + " "; } else if ((now.getTime() - time) < (60 * 60 * 1000)) { return (now.getTime() - time) / 1000 / 60 + "? " + nowHourAndMinute + " "; } else if ((now.getTime() - time) < (24 * 60 * 60 * 1000)) { return (now.getTime() - time) / 1000 / 60 / 60 + "?? " + nowHourAndMinute + " "; } else if (time >= nowDay) { return " " + nowHourAndMinute; } else if (time >= yesterday) { return " " + nowHourAndMinute; } else { return toDoubleDigit(orginalTime.getMonth()) + "-" + toDoubleDigit(orginalTime.getDate()) + " " + nowHourAndMinute + ":" + toDoubleDigit(orginalTime.getSeconds()); } }
From source file:graph.module.DateParseModule.java
@SuppressWarnings("deprecation") private DAGNode parseDate(SimpleDateFormat sdf, String dateStr) { try {/*from www.j a v a 2 s . c o m*/ ParsePosition position = new ParsePosition(0); Date date = sdf.parse(dateStr, position); if (position.getIndex() != dateStr.length()) { // Throw an exception or whatever else you want to do return null; } String pattern = sdf.toPattern(); StringBuilder buffer = new StringBuilder(); boolean addFurther = false; int brackets = 0; if (addFurther || pattern.contains("d")) { addFurther = true; buffer.append("(" + CommonConcepts.DAYFN.getID() + " '" + date.getDate() + " "); brackets++; } if (addFurther || pattern.contains("M")) { addFurther = true; buffer.append("(" + CommonConcepts.MONTHFN.getID() + " " + MONTH_FORMATTER.format(date) + " "); brackets++; } if (pattern.contains("y")) { buffer.append("(" + CommonConcepts.YEARFN.getID() + " '" + (date.getYear() + 1900)); brackets++; } else if (addFurther) buffer.append(CommonConcepts.THE_YEAR.getID()); for (int i = 0; i < brackets; i++) buffer.append(")"); return (DAGNode) dag_.findOrCreateNode(buffer.toString(), null); } catch (Exception e) { } return null; }
From source file:eionet.util.Util.java
/** * A method for formatting the given timestamp into a String released_datasets.jsp. * * @param timestamp Milliseconds since 1 January 1970. *///from w ww.j a v a2s. c o m private static String releasedDate(long timestamp, boolean shortMonth) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth()); String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; Hashtable months = new Hashtable(); months.put("0", "January"); months.put("1", "February"); months.put("2", "March"); months.put("3", "April"); months.put("4", "May"); months.put("5", "June"); months.put("6", "July"); months.put("7", "August"); months.put("8", "September"); months.put("9", "October"); months.put("10", "November"); months.put("11", "December"); String time = day + " " + (shortMonth ? months.get(month).toString().substring(0, 3) : months.get(month)) + " " + year; return time; }
From source file:com.krawler.common.util.StringUtil.java
public static Boolean issameDatesExTime(Date olddate, String newdatestr) { Date newdate = new Date(newdatestr); return newdate.getDate() == olddate.getDate() && newdate.getYear() == olddate.getYear() && newdate.getMonth() == olddate.getMonth(); }