Search in sources :

Example 41 with DateFormat

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());
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 42 with DateFormat

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()));
}
Also used : DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 43 with DateFormat

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);
    }
}
Also used : TimeZone(java.util.TimeZone) JSONObject(org.json.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) JSONArray(org.json.JSONArray) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JSONException(org.json.JSONException) IOException(java.io.IOException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 44 with DateFormat

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);
}
Also used : MifosException(org.mifos.core.MifosException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CustomerHierarchyDto(org.mifos.dto.domain.CustomerHierarchyDto) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Example 45 with DateFormat

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);
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Birthday(ezvcard.property.Birthday) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

DateFormat (java.text.DateFormat)646 SimpleDateFormat (java.text.SimpleDateFormat)486 Date (java.util.Date)315 ParseException (java.text.ParseException)132 Calendar (java.util.Calendar)78 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)48 IOException (java.io.IOException)43 File (java.io.File)31 HashMap (java.util.HashMap)27 GregorianCalendar (java.util.GregorianCalendar)24 TimeZone (java.util.TimeZone)23 Locale (java.util.Locale)18 Timestamp (java.sql.Timestamp)17 List (java.util.List)14 InputStream (java.io.InputStream)12 DateTime (org.joda.time.DateTime)11 Map (java.util.Map)10 Matcher (java.util.regex.Matcher)8 TestBean (org.springframework.tests.sample.beans.TestBean)8