Example usage for org.joda.time.format DateTimeFormatter print

List of usage examples for org.joda.time.format DateTimeFormatter print

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatter print.

Prototype

public String print(ReadablePartial partial) 

Source Link

Document

Prints a ReadablePartial to a new String.

Usage

From source file:com.linagora.obm.ui.scenario.event.EventStepdefs.java

License:Open Source License

private String expectedEventDatesTitle(int beginHour, int beginMin, int endHour, int endMin) {
    DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm");
    return timeFormatter.print(new DateTime().withTime(beginHour, beginMin, 0, 0)) + " - "
            + timeFormatter.print(new DateTime().withTime(endHour, endMin, 0, 0));
}

From source file:com.linagora.obm.ui.scenario.event.EventStepdefs.java

License:Open Source License

@And("^event \"([^\"]*)\" appears every year at (\\d+)/(\\d+)/(\\d+) from (\\d+):(\\d+) to (\\d+):(\\d+)$")
public void eventAppearsEveryYear(String title, int day, int month, int year, int beginHour, int beginMin,
        int endHour, int endMin) {

    processedCalendarPage.calendarViewWidget().listView();
    processedCalendarPage.calendarCalRangeWidget().monthlyEvents();

    DateTime dateTime = new DateTime().withDate(year, month, day);
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
    String expectedEventDatesTitle = expectedEventDatesTitle(beginHour, beginMin, endHour, endMin);

    for (int numberOfChecks = 0; numberOfChecks < 3; numberOfChecks++) {
        boolean found = false;

        dateTime = dateTime.plusYears(1);
        for (int monthIterator = 0; monthIterator < 12; monthIterator++) {
            processedCalendarPage.calendarNavBarWidget().nextPage();
            found = isYearlyEventInPrintedMonth(title, dateTimeFormatter.print(dateTime),
                    expectedEventDatesTitle);
            if (found) {
                break;
            }//from   w  w  w  .  ja v a 2  s. c o  m
        }

        assertThat(found).isTrue();
    }
}

From source file:com.liteoc.logic.expressionTree.ArithmeticOpNode.java

License:LGPL

private String calculateGenericDate(String value1, String value2) {
    DateMidnight dm = new DateMidnight(ExpressionTreeHelper.getDate(value1).getTime());
    DateTimeFormatter fmt = ISODateTimeFormat.date();
    switch (op) {
    case PLUS: {/*ww  w  .  j a  va2s. c o m*/
        dm = dm.plusDays(Double.valueOf(value2).intValue());
        return fmt.print(dm);
    }
    case MINUS: {
        dm = dm.minusDays(Double.valueOf(value2).intValue());
        return fmt.print(dm);
    }
    default:
        return null; // Bad operator!
    }
}

From source file:com.liteoc.logic.expressionTree.OpenClinicaVariableNode.java

License:LGPL

private String calculateVariable() {
    if (number.equals("_CURRENT_DATE")) {
        DateMidnight dm = new DateMidnight();
        DateTimeFormatter fmt = ISODateTimeFormat.date();
        return fmt.print(dm);
    }/*w w  w  .  j a  v a2 s .c om*/
    return null;
}

From source file:com.liteoc.logic.expressionTree.OpenClinicaVariableNode.java

License:LGPL

private String testCalculateVariable() {
    if (number.equals("_CURRENT_DATE")) {
        DateMidnight dm = new DateMidnight();
        DateTimeFormatter fmt = ISODateTimeFormat.date();
        return fmt.print(dm);
    }//  ww  w . ja  v  a  2  s . c  om
    return null;
}

From source file:com.loadtesting.showcase.springmvc.model.converter.JodaTimeConverter.java

License:Apache License

public JodaTimeForm convert(JodaTimeForm form) throws ParseException {
    DateTimeFormatter format1 = getFormat(form.getFromTimeZone());
    DateTime date = format1.parseDateTime(form.getInputDate());
    DateTimeFormatter format2 = getFormat(form.getToTimeZone());
    String outputDate = format2.print(date);
    JodaTimeForm resultForm = new JodaTimeForm();
    resultForm.setInputDate(form.getInputDate());
    resultForm.setFromTimeZone(form.getFromTimeZone());
    resultForm.setToTimeZone(form.getToTimeZone());
    resultForm.setOutputDate(outputDate);
    return resultForm;
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

License:Open Source License

static String getTitle(String key) {
    String updateTime = m_prefs.get("updateTime", "nie");
    DateTime uT = new DateTime(updateTime);
    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd-MM-yyyy HH:mm:ss");
    String title = m_rb.getString(key) + " (aktualisiert am " + fmt.print(uT) + ")";
    return title;
}

From source file:com.meetingninja.csse.meetings.MeetingItemAdapter.java

License:Apache License

private String getTimeSpan(long start, long end, boolean allDay) {
    StringBuilder spanBuilder = new StringBuilder();
    boolean is24 = android.text.format.DateFormat.is24HourFormat(context.getApplicationContext());
    DateTimeFormatter timeFormat = is24 ? MyDateUtils.JODA_24_TIME_FORMAT : MyDateUtils.JODA_12_TIME_FORMAT;
    DateTimeFormatter dateFormat = DateTimeFormat.forPattern("MMMM dd, yyyy");
    spanBuilder.append(dateFormat.print(start));
    if (!allDay) {
        spanBuilder.append(", " + timeFormat.print(start) + " - ");
        spanBuilder.append(dateFormat.print(end));
        spanBuilder.append(", " + timeFormat.print(end));
    }//from  www .  ja  va  2  s .  c  om

    return spanBuilder.toString();

}

From source file:com.meisolsson.githubsdk.core.FormattedTimeAdapter.java

License:Apache License

@ToJson
String toJson(@FormattedTime Date date) {
    DateTimeFormatter formats = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
    return formats.print(date.getTime());
}

From source file:com.metamx.druid.indexer.path.GranularityPathSpec.java

License:Open Source License

@Override
public Job addInputPaths(HadoopDruidIndexerConfig config, Job job) throws IOException {
    final Set<Interval> intervals = Sets.newTreeSet(Comparators.intervals());
    for (Interval segmentInterval : config.getSegmentGranularIntervals()) {
        for (Interval dataInterval : dataGranularity.getIterable(segmentInterval)) {
            intervals.add(dataInterval);
        }/* w w w  .j  ava2 s.  c o m*/
    }

    Path betaInput = new Path(inputPath);
    FileSystem fs = betaInput.getFileSystem(job.getConfiguration());
    Set<String> paths = Sets.newTreeSet();
    Pattern fileMatcher = Pattern.compile(filePattern);

    DateTimeFormatter customFormatter = null;
    if (pathFormat != null) {
        customFormatter = DateTimeFormat.forPattern(pathFormat);
    }

    for (Interval interval : intervals) {
        DateTime t = interval.getStart();
        String intervalPath = null;
        if (customFormatter != null) {
            intervalPath = customFormatter.print(t);
        } else {
            intervalPath = dataGranularity.toPath(t);
        }

        Path granularPath = new Path(betaInput, intervalPath);
        log.info("Checking path[%s]", granularPath);
        for (FileStatus status : FSSpideringIterator.spiderIterable(fs, granularPath)) {
            final Path filePath = status.getPath();
            if (fileMatcher.matcher(filePath.toString()).matches()) {
                paths.add(filePath.toString());
            }
        }
    }

    for (String path : paths) {
        log.info("Appending path[%s]", path);
        FileInputFormat.addInputPath(job, new Path(path));
    }

    return job;
}