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 DateTag method getUserFormat.
String getUserFormat(Locale locale) {
// the following line will be removed when date is localized
locale = Locale.UK;
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
return ((SimpleDateFormat) df).toPattern();
}
use of java.text.DateFormat in project head by mifos.
the class LocalizationConverter method getDateSeparator.
public String getDateSeparator(Locale locale, int dateFormat) {
String separator = "";
DateFormat format = DateFormat.getDateInstance(dateFormat, locale);
String now = format.format(new DateTimeService().getCurrentJavaDateTime());
char[] chArray = now.toCharArray();
for (char element : chArray) {
if (Character.isDigit(element) == false) {
separator = String.valueOf(element);
break;
}
}
return separator;
}
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);
}
Aggregations