Example usage for org.joda.time.format DateTimeFormat fullDate

List of usage examples for org.joda.time.format DateTimeFormat fullDate

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormat fullDate.

Prototype

public static DateTimeFormatter fullDate() 

Source Link

Document

Creates a format that outputs a full date format.

Usage

From source file:org.mpardalos.homework_plus.TaskAdd.java

License:Open Source License

public void onDateEntered(LocalDate date) {
    EditText dateInput = (EditText) findViewById(R.id.due_date_input);
    DateTimeFormatter df = DateTimeFormat.fullDate().withLocale(Locale.getDefault());
    dateInput.setText(date.toString(df));
    dateInput.setTag(R.id.due_date, date);
}

From source file:org.mpardalos.homework_plus.TaskEdit.java

License:Open Source License

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    JodaTimeAndroid.init(this);

    Task task = getIntent().getParcelableExtra("task");

    Spinner subjectSpinner = (Spinner) findViewById(R.id.subject_input);
    ((Spinner) findViewById(R.id.subject_input)).setSelection(getIndex(subjectSpinner, task.getSubject()));

    DateTimeFormatter df = DateTimeFormat.fullDate().withLocale(Locale.getDefault());
    EditText dueDateInput = (EditText) findViewById(R.id.due_date_input);

    dueDateInput.setText(task.getDueDate().toString(df));
    dueDateInput.setTag(R.id.due_date, task.getDueDate());

    ((EditText) findViewById(R.id.description_input)).setText(task.getDescription());

    this.mPhotoFile = task.getPhotoFile();
    if (mPhotoFile != null) {
        findViewById(R.id.image_heading).setVisibility(View.VISIBLE);
        loadImageToImageView(mPhotoFile);
    }/*from ww  w .j  a  v a  2 s  .  c  o  m*/
}

From source file:org.sakaiproject.tool.assessment.ui.bean.delivery.SectionContentsBean.java

License:Educational Community License

public void setMetaData(SectionDataIfc section) {

    if (section.getSectionMetaDataByLabel(SectionDataIfc.AUTHOR_TYPE) != null) {
        Integer authortype = new Integer(section.getSectionMetaDataByLabel(SectionDataIfc.AUTHOR_TYPE));
        setSectionAuthorType(authortype);

        if (section.getSectionMetaDataByLabel(SectionDataIfc.AUTHOR_TYPE)
                .equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL.toString())) {
            if (section.getSectionMetaDataByLabel(SectionDataIfc.NUM_QUESTIONS_DRAWN) != null) {
                Integer numberdrawn = new Integer(
                        section.getSectionMetaDataByLabel(SectionDataIfc.NUM_QUESTIONS_DRAWN));
                setNumberToBeDrawn(numberdrawn);
            }//from  w w  w  . j  a v  a2 s . com

            if (section.getSectionMetaDataByLabel(SectionDataIfc.POOLID_FOR_RANDOM_DRAW) != null) {
                Long poolid = new Long(
                        section.getSectionMetaDataByLabel(SectionDataIfc.POOLID_FOR_RANDOM_DRAW));
                setPoolIdToBeDrawn(poolid);
            }
            if (section.getSectionMetaDataByLabel(SectionDataIfc.POOLNAME_FOR_RANDOM_DRAW) != null) {
                String poolname = section.getSectionMetaDataByLabel(SectionDataIfc.POOLNAME_FOR_RANDOM_DRAW);
                setPoolNameToBeDrawn(poolname);

                String randomDrawDate = section
                        .getSectionMetaDataByLabel(SectionDataIfc.QUESTIONS_RANDOM_DRAW_DATE);
                if (randomDrawDate != null && !"".equals(randomDrawDate)) {

                    try {

                        // bjones86 - SAM-1604
                        DateTime drawDate;
                        DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); //The Date Time is in ISO format
                        try {
                            drawDate = fmt.parseDateTime(randomDrawDate);
                        } catch (Exception ex) {
                            Date date = null;
                            try {
                                // Old code produced dates that appeard like java.util.Date.toString() in the database
                                // This means it's possible that the database contains dates in multiple formats
                                // We'll try parsing Date.toString()'s format first.
                                // Date.toString is locale independent. So this SimpleDateFormat using Locale.US should guarantee that this works on all machines:
                                DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
                                // parse can either throw an exception or return null
                                date = df.parse(randomDrawDate);
                            } catch (Exception e) {
                                // failed to parse. Not worth logging yet because we will try again with another format
                            }

                            if (date == null) {
                                DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ");
                                // If this throws an exception, it's caught below. This is appropriate.
                                date = df.parse(randomDrawDate);
                            }

                            if (date == null) {
                                // Nothing has worked
                                throw new IllegalArgumentException("Unable to parse date " + randomDrawDate);
                            } else {
                                drawDate = new DateTime(date);
                            }
                        }

                        //We need the locale to localize the output string
                        Locale loc = new ResourceLoader().getLocale();
                        String drawDateString = DateTimeFormat.fullDate().withLocale(loc).print(drawDate);
                        String drawTimeString = DateTimeFormat.fullTime().withLocale(loc).print(drawDate);
                        setRandomQuestionsDrawDate(drawDateString);
                        setRandomQuestionsDrawTime(drawTimeString);

                    } catch (Exception e) {
                        log.error("Unable to parse date text: " + randomDrawDate, e);
                    }
                }
            }
        }

    } else {

        setSectionAuthorType(SectionDataIfc.QUESTIONS_AUTHORED_ONE_BY_ONE);
    }
    if (section.getSectionMetaDataByLabel(SectionDataIfc.QUESTIONS_ORDERING) != null) {
        Integer questionorder = new Integer(
                section.getSectionMetaDataByLabel(SectionDataIfc.QUESTIONS_ORDERING));
        setQuestionOrdering(questionorder);
    } else {
        setQuestionOrdering(SectionDataIfc.AS_LISTED_ON_ASSESSMENT_PAGE);
    }

}

From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeDialect.java

License:Open Source License

@Override
public Set<IProcessor> getProcessors() {
    Set<IProcessor> processors = new HashSet<IProcessor>();
    processors.add(new JodaTimeFormatProcessor("fullDate", DateTimeFormat.fullDate()));
    processors.add(new JodaTimeFormatProcessor("fullDateTime", DateTimeFormat.fullDateTime()));
    processors.add(new JodaTimeFormatProcessor("fullTime", DateTimeFormat.fullTime()));
    processors.add(new JodaTimeFormatProcessor("longDate", DateTimeFormat.longDate()));
    processors.add(new JodaTimeFormatProcessor("longDateTime", DateTimeFormat.longDateTime()));
    processors.add(new JodaTimeFormatProcessor("longTime", DateTimeFormat.longTime()));
    processors.add(new JodaTimeFormatProcessor("mediumDate", DateTimeFormat.mediumDate()));
    processors.add(new JodaTimeFormatProcessor("mediumDateTime", DateTimeFormat.mediumDateTime()));
    processors.add(new JodaTimeFormatProcessor("mediumTime", DateTimeFormat.mediumTime()));
    processors.add(new JodaTimeFormatProcessor("shortDate", DateTimeFormat.shortDate()));
    processors.add(new JodaTimeFormatProcessor("shortDateTime", DateTimeFormat.shortDateTime()));
    processors.add(new JodaTimeFormatProcessor("shortTime", DateTimeFormat.shortTime()));
    processors.add(new JodaTimeFormatProcessor("isoDateTime", ISODateTimeFormat.dateTime()));
    return processors;
}

From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeExpressionObject.java

License:Open Source License

/**
 * Formats the datetime with a JodaTime full date format
 *
 * @param dateTime/* ww  w. ja  va 2 s .  co  m*/
 *            The datetime
 * @return The formatted date
 */
public String fullDate(DateTime dateTime) {
    return format(dateTime, DateTimeFormat.fullDate());
}

From source file:ru.caramel.juniperbot.core.message.resolver.DateTimePlaceholderResolver.java

License:Open Source License

@Override
public Object getChild(String name) {
    switch (name) {
    case "shortTime":
        return format(DateTimeFormat.shortTime());
    case "mediumTime":
        return format(DateTimeFormat.mediumTime());
    case "longTime":
        return format(DateTimeFormat.longTime());
    case "fullTime":
        return format(DateTimeFormat.fullTime());
    case "shortDate":
        return format(DateTimeFormat.shortDate());
    case "mediumDate":
        return format(DateTimeFormat.mediumDate());
    case "longDate":
        return format(DateTimeFormat.longDate()); // The same as medium
    case "fullDate":
        return format(DateTimeFormat.fullDate());
    case "shortDateTime":
        return format(DateTimeFormat.shortDateTime());
    case "mediumDateTime":
        return format(DateTimeFormat.mediumDateTime());
    case "longDateTime":
        return format(DateTimeFormat.longDateTime());
    case "fullDateTime":
        return format(DateTimeFormat.fullDateTime());
    }// www  .  j  a va 2  s  .c  o  m
    return null;
}

From source file:ru.touchin.templates.calendar.CalendarAdapter.java

License:Apache License

/**
 * Constructor that takes all necessary data to initialize.
 *
 * @param startDate   First date in the calendar range;
 * @param endDate     Last date (not inclusive) in the calendar range;
 * @param monthsNames String array of months names where #0 is January and #11 is December.
 *///  w  w w  .  ja v  a  2s .co  m
public CalendarAdapter(@NonNull final DateTime startDate, @NonNull final DateTime endDate,
        @Nullable final String... monthsNames) {
    super();
    if (monthsNames != null && monthsNames.length == MONTHS_IN_YEAR) {
        this.monthsNames = monthsNames;
    }
    calendarItems = CalendarUtils.fillRanges(startDate, endDate);
    if (calendarItems.isEmpty()) {
        throw new ShouldNotHappenException(
                "There is no items in calendar with startDate: " + DateTimeFormat.fullDate().print(startDate)
                        + ", and endDate: " + DateTimeFormat.fullDate().print(endDate));
    }
}