use of java.text.DateFormat in project head by mifos.
the class MeetingAction method setValuesInActionForm.
private void setValuesInActionForm(MeetingActionForm form, MeetingBO meeting) {
if (meeting.isWeekly()) {
form.setFrequency(RecurrenceType.WEEKLY.getValue().toString());
form.setWeekDay(meeting.getMeetingDetails().getWeekDay().getValue().toString());
form.setRecurWeek(meeting.getMeetingDetails().getRecurAfter().toString());
Date meetingStartDate = meeting.getMeetingStartDate();
if (meetingStartDate != null) {
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
form.setMeetingStartDate(df.format(meetingStartDate));
}
} else if (meeting.isDaily()) {
form.setFrequency(RecurrenceType.DAILY.getValue().toString());
form.setRecurDay(meeting.getMeetingDetails().getRecurAfter().toString());
Date meetingStartDate = meeting.getMeetingStartDate();
if (meetingStartDate != null) {
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
form.setMeetingStartDate(df.format(meetingStartDate));
}
} else if (meeting.isMonthly()) {
form.setFrequency(RecurrenceType.MONTHLY.getValue().toString());
if (meeting.isMonthlyOnDate()) {
form.setMonthType("1");
form.setDayRecurMonth(meeting.getMeetingDetails().getRecurAfter().toString());
form.setMonthDay(meeting.getMeetingDetails().getDayNumber().toString());
} else {
form.setMonthType("2");
form.setRecurMonth(meeting.getMeetingDetails().getRecurAfter().toString());
form.setMonthWeek(meeting.getMeetingDetails().getWeekDay().getValue().toString());
form.setMonthRank(meeting.getMeetingDetails().getWeekRank().getValue().toString());
}
}
form.setMeetingPlace(meeting.getMeetingPlace());
}
use of java.text.DateFormat in project hudson-2.x by hudson.
the class Run method doBuildTimestamp.
/**
* Returns the build time stamp in the body.
*/
public void doBuildTimestamp(StaplerRequest req, StaplerResponse rsp, @QueryParameter String format) throws IOException {
rsp.setContentType("text/plain");
rsp.setCharacterEncoding("US-ASCII");
rsp.setStatus(HttpServletResponse.SC_OK);
DateFormat df = format == null ? DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH) : new SimpleDateFormat(format, req.getLocale());
rsp.getWriter().print(df.format(getTime()));
}
use of java.text.DateFormat in project pinot by linkedin.
the class SegmentMetadataImpl method toJson.
/**
* Converts segment metadata to json
* @param columnFilter list only the columns in the set. Lists all the columns if
* the parameter value is null
* @return json representation of segment metadata
*/
public JSONObject toJson(@Nullable Set<String> columnFilter) throws JSONException {
JSONObject rootMeta = new JSONObject();
try {
rootMeta.put("segmentName", _segmentName);
rootMeta.put("schemaName", _schema != null ? _schema.getSchemaName() : JSONObject.NULL);
rootMeta.put("crc", _crc);
rootMeta.put("creationTimeMillis", _creationTime);
TimeZone timeZone = TimeZone.getTimeZone("UTC");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSS' UTC'");
dateFormat.setTimeZone(timeZone);
String creationTimeStr = _creationTime != Long.MIN_VALUE ? dateFormat.format(new Date(_creationTime)) : "";
rootMeta.put("creationTimeReadable", creationTimeStr);
rootMeta.put("timeGranularitySec", _timeGranularity != null ? _timeGranularity.getStandardSeconds() : null);
if (_timeInterval == null) {
rootMeta.put("startTimeMillis", (String) null);
rootMeta.put("startTimeReadable", "null");
rootMeta.put("endTimeMillis", (String) null);
rootMeta.put("endTimeReadable", "null");
} else {
rootMeta.put("startTimeMillis", _timeInterval.getStartMillis());
rootMeta.put("startTimeReadable", _timeInterval.getStart().toString());
rootMeta.put("endTimeMillis", _timeInterval.getEndMillis());
rootMeta.put("endTimeReadable", _timeInterval.getEnd().toString());
}
rootMeta.put("pushTimeMillis", _pushTime);
String pushTimeStr = _pushTime != Long.MIN_VALUE ? dateFormat.format(new Date(_pushTime)) : "";
rootMeta.put("pushTimeReadable", pushTimeStr);
rootMeta.put("refreshTimeMillis", _refreshTime);
String refreshTimeStr = _refreshTime != Long.MIN_VALUE ? dateFormat.format(new Date(_refreshTime)) : "";
rootMeta.put("refreshTimeReadable", refreshTimeStr);
rootMeta.put("segmentVersion", _segmentVersion.toString());
rootMeta.put("hasStarTree", hasStarTree());
rootMeta.put("creatorName", _creatorName == null ? JSONObject.NULL : _creatorName);
rootMeta.put("paddingCharacter", String.valueOf(_paddingCharacter));
rootMeta.put("hllLog2m", _hllLog2m);
JSONArray columnsJson = new JSONArray();
ObjectMapper mapper = new ObjectMapper();
for (String column : _allColumns) {
if (columnFilter != null && !columnFilter.contains(column)) {
continue;
}
ColumnMetadata columnMetadata = _columnMetadataMap.get(column);
JSONObject columnJson = new JSONObject(mapper.writeValueAsString(columnMetadata));
columnsJson.put(columnJson);
}
rootMeta.put("columns", columnsJson);
return rootMeta;
} catch (Exception e) {
LOGGER.error("Failed to convert field to json for segment: {}", _segmentName, e);
throw new RuntimeException("Failed to convert segment metadata to json", e);
}
}
use of java.text.DateFormat in project head by mifos.
the class HomePageController method loadLoanOfficerCustomersHierarchyForSelectedDay.
private void loadLoanOfficerCustomersHierarchyForSelectedDay(Short userId, ModelAndView modelAndView, CustomerSearchFormBean customerSearchFormBean) throws MifosException {
CustomerHierarchyDto hierarchy;
List<String> nearestDates = new ArrayList<String>();
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", personnelServiceFacade.getUserPreferredLocale());
Date selectedDate = new LocalDate().toDateMidnight().toDate();
DateTime nextDate = new DateTime();
for (int i = 0; i < 7; i++) {
nearestDates.add(formatter.format(nextDate.toDate()));
nextDate = nextDate.plusDays(1);
}
if (customerSearchFormBean.getSelectedDateOption() != null) {
try {
selectedDate = formatter.parse(customerSearchFormBean.getSelectedDateOption());
} catch (ParseException e) {
throw new MifosException(e);
}
}
hierarchy = personnelServiceFacade.getLoanOfficerCustomersHierarchyForDay(userId, new DateTime(selectedDate));
modelAndView.addObject("nearestDates", nearestDates);
modelAndView.addObject("hierarchy", hierarchy);
}
use of java.text.DateFormat in project qksms by moezbhatti.
the class ContactOperations method convertBirthdays.
private void convertBirthdays(List<NonEmptyContentValues> contentValues, VCard vcard) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
for (Birthday birthday : vcard.getBirthdays()) {
Date date = birthday.getDate();
if (date == null) {
continue;
}
NonEmptyContentValues cv = new NonEmptyContentValues(ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE);
cv.put(ContactsContract.CommonDataKinds.Event.TYPE, ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY);
cv.put(ContactsContract.CommonDataKinds.Event.START_DATE, df.format(date));
contentValues.add(cv);
}
}
Aggregations