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:ca.farrelltonsolar.classic.ModbusTask.java

License:Apache License

private void loadBoilerPlateInfo() {
    try {/*from  w ww.  ja v a 2s .c o m*/
        Register[] registers = modbusMaster.readMultipleRegisters(4100, 32);

        if (registers != null && registers.length == 32) {
            short reg1 = (short) registers[0].getValue();
            String model = String.format("Classic %d (rev %d)", reg1 & 0x00ff, reg1 >> 8);
            chargeControllerInfo.setModel(model);
            int buildYear = registers[1].getValue();
            int buildMonthDay = registers[2].getValue();
            DateTime buildDate = new DateTime(buildYear, (buildMonthDay >> 8), (buildMonthDay & 0x00ff), 0, 0);
            chargeControllerInfo.setBuildDate(DateTimeFormat.fullDate().print(buildDate));
            short reg6 = registers[5].toShort();
            short reg7 = registers[6].toShort();
            short reg8 = registers[7].toShort();
            String macAddress = String.format("%02x:%02x:%02x:%02x:%02x:%02x", reg8 >> 8, reg8 & 0x00ff,
                    reg7 >> 8, reg7 & 0x00ff, reg6 >> 8, reg6 & 0x00ff);
            chargeControllerInfo.setMacAddress(macAddress);
            float reg22 = (float) registers[21].getValue();
            chargeControllerInfo.setLastVOC(reg22 / 10);
        }
        registers = modbusMaster.readMultipleRegisters(4244, 2);
        if (registers != null && registers.length == 2) {
            short reg4245 = (short) registers[0].getValue();
            chargeControllerInfo.setNominalBatteryVoltage(reg4245);
        }
        registers = modbusMaster.readMultipleRegisters(16386, 4);
        if (registers != null && registers.length == 4) {
            short reg16387 = registers[0].toShort();
            short reg16388 = registers[1].toShort();
            short reg16389 = registers[2].toShort();
            short reg16390 = registers[3].toShort();
            chargeControllerInfo.setAppVersion(String.format("%d", (reg16388 << 16) + reg16387));
            chargeControllerInfo.setNetVersion(String.format("%d", (reg16390 << 16) + reg16389));
        }
    } catch (Exception e) {
        Log.w(getClass().getName(), "loadBoilerPlateInfo failed ex: %s", e);
    }
}

From source file:com.helger.datetime.format.PDTFormatter.java

License:Apache License

/**
 * Get the full date formatter for the passed locale.
 *
 * @param aDisplayLocale/* www.j av a  2 s. co m*/
 *        The display locale to be used. May be <code>null</code>.
 * @return The created date time formatter. Never <code>null</code>.
 */
@Nonnull
public static DateTimeFormatter getFullFormatterDate(@Nullable final Locale aDisplayLocale) {
    return getWithLocaleAndChrono(DateTimeFormat.fullDate(), aDisplayLocale);
}

From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java

License:Open Source License

/**
 * Checks a string to see if it matches one of the standard DateTimeFormat
 * style patterns: full, long, medium, short, or default.
 *///from   w  ww.j  av a2 s. c  o m
private static DateTimeFormatter getDateStyle(String style, Locale locale, DateTimeZone zone) {
    final DateTimeFormatter ret;

    if (style.equalsIgnoreCase("full")) {
        ret = DateTimeFormat.fullDate();
    } else if (style.equalsIgnoreCase("long")) {
        ret = DateTimeFormat.longDate();
    } else if (style.equalsIgnoreCase("medium")) {
        ret = DateTimeFormat.mediumDate();
    } else if (style.equalsIgnoreCase("short")) {
        ret = DateTimeFormat.shortDate();
    } else if (style.equalsIgnoreCase("none")) {
        ret = null;
    } else {
        ret = DateTimeFormat.forPattern(style);
    }

    return ret == null ? null : ret.withLocale(locale).withZone(zone);
}

From source file:com.moss.joda.swing.LiveDatePicker.java

License:Open Source License

public LiveDatePicker() {
    formats.add(DateTimeFormat.shortDate());
    formats.add(ISODateTimeFormat.date());
    formats.add(ISODateTimeFormat.basicDate());
    formats.add(DateTimeFormat.mediumDate());
    formats.add(DateTimeFormat.fullDate());
    formats.add(DateTimeFormat.longDate());

    //      p = new JXDatePicker();
    //      pButton = p.getComponent(1);
    //      p.getEditor().setVisible(false);

    pButton = new JButton("^");
    pButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Point p = pButton.getLocation();
            popup.show(pButton, 0, 0);/* ww  w .j  a v a 2s  . co m*/

        }
    });
    popup.add(new DateSelectionListener() {
        public void dateSelected(YearMonthDay date) {
            setDate(date);
            fireSelection();
        }
    });

    t.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            handle();
        }

        public void insertUpdate(DocumentEvent e) {
            handle();
        }

        public void removeUpdate(DocumentEvent e) {
            handle();
        }

        void handle() {
            if (!uiUpdating) {
                String text = t.getText();
                YearMonthDay date = null;
                for (int x = 0; date == null && x < formats.size(); x++) {
                    DateTimeFormatter f = formats.get(x);
                    try {
                        date = f.parseDateTime(text).toYearMonthDay();
                    } catch (IllegalArgumentException e) {
                    }
                }
                value = date;
                if (date != null) {
                    popup.setDate(date);
                }
                fireSelection();
            }
        }

    });

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.ipadx = 10;
    add(t, c);
    c.weightx = 0;
    c.ipadx = 0;
    //      c.insets.left = 5;
    add(pButton, c);

    setDate(new YearMonthDay());
}

From source file:com.sapienter.jbilling.server.metafields.MetaFieldBL.java

License:Open Source License

public static final MetaFieldValue createValueFromDataType(MetaField metaField, Object value,
        DataType dataType) {// w w  w  . j a v  a  2  s  . c  o  m

    try {

        switch (dataType) {
        case STRING:
        case STATIC_TEXT:
        case TEXT_AREA:
        case ENUMERATION:
        case SCRIPT:
            StringMetaFieldValue stringMetaFieldValue = new StringMetaFieldValue(metaField);
            if (value != null) {
                stringMetaFieldValue.setValue(value.toString());
            }
            return stringMetaFieldValue;

        case INTEGER:
            IntegerMetaFieldValue integerMetaFieldValue = new IntegerMetaFieldValue(metaField);
            if (value != null) {
                integerMetaFieldValue.setValue(Integer.valueOf(value.toString()));
            }
            return integerMetaFieldValue;

        case DECIMAL:
            DecimalMetaFieldValue decimalMetaFieldValue = new DecimalMetaFieldValue(metaField);
            if (value != null) {
                decimalMetaFieldValue.setValue(new BigDecimal(value.toString()));
            }
            return decimalMetaFieldValue;

        case BOOLEAN:
            BooleanMetaFieldValue booleanMetaFieldValue = new BooleanMetaFieldValue(metaField);
            if (value != null) {
                booleanMetaFieldValue.setValue(Boolean.valueOf(value.toString()));
            }
            return booleanMetaFieldValue;

        case DATE:
            DateMetaFieldValue dateMetaFieldValue = new DateMetaFieldValue(metaField);
            if (value != null) {
                dateMetaFieldValue.setValue(DateTimeFormat.fullDate().parseDateTime(value.toString()).toDate());
            }
            return dateMetaFieldValue;

        case JSON_OBJECT:
            JsonMetaFieldValue jsonMetaFieldValue = new JsonMetaFieldValue(metaField);
            if (value != null) {
                jsonMetaFieldValue.setValue(value.toString());
            }
            return jsonMetaFieldValue;

        case LIST:
            ListMetaFieldValue listMetaFieldValue = new ListMetaFieldValue(metaField);
            if (value != null) {
                listMetaFieldValue.setValue(Arrays.asList(new String[] { value.toString() }));
            }
            return listMetaFieldValue;
        }

    } catch (Exception e) {
        // cant create a value//
        return null;
    }
    return null;
}

From source file:com.sheepdog.mashmesh.servlets.AcceptPickupServlet.java

License:Apache License

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    Objectify rideRequestOfy = OfyService.transactionOfy();

    try {/*from   www . j  av  a2s. co  m*/
        String rideRequestId = req.getParameter("rideRequestId");
        Preconditions.checkNotNull(rideRequestId);

        RideRequest rideRequest = rideRequestOfy.get(RideRequest.class, Long.parseLong(rideRequestId));
        UserProfile userProfile = (UserProfile) req.getAttribute("userProfile");

        VolunteerProfile volunteerProfile = rideRequest.getPendingVolunteerProfile();

        // Make sure that we're not trying to answer a pickup request meant for someone else.
        if (!volunteerProfile.getUserId().equals(userProfile.getUserId())) {
            resp.setStatus(403);
            // TODO: Explanatory page
            return;
        }

        // TODO: Centralize this logic with the rest of the notification logic
        RideRecord rideRecord = rideRequest.getPendingRideRecord();
        rideRecord.setExportable(true);
        OfyService.ofy().put(rideRecord);

        PickupNotification.sendPatientNotification(rideRequest, userProfile);

        rideRequestOfy.delete(rideRequest);
        rideRequestOfy.getTxn().commit();

        // TODO: Make sure that pickup requests timeout and trigger a rejection.

        DateTimeFormatter dateFormatter = DateTimeFormat.fullDate();
        DateTimeFormatter timeFormatter = DateTimeFormat.shortTime();

        VelocityContext context = new VelocityContext();
        context.put("userProfile", userProfile);
        context.put("isAdmin", UserServiceFactory.getUserService().isUserAdmin());
        context.put("patientProfile", rideRequest.getPatientProfile());
        context.put("appointmentAddress", rideRequest.getAppointmentAddress());
        context.put("appointmentTime", timeFormatter.print(rideRequest.getAppointmentTime()));
        context.put("appointmentDate", dateFormatter.print(rideRequest.getAppointmentTime()));
        context.put("pickupTime", timeFormatter.print(rideRecord.getPickupTime()));

        resp.setContentType("text/html");
        Template template = VelocityUtils.getInstance().getTemplate(ACCEPT_PICKUP_TEMPLATE_PATH);
        template.merge(context, resp.getWriter());
    } catch (MessagingException e) {
        logger.log(Level.SEVERE, "Failed to send patient notification", e);
        resp.setStatus(500);
    } finally {
        if (rideRequestOfy.getTxn().isActive()) {
            rideRequestOfy.getTxn().rollback();
        }
    }
}

From source file:com.vityuk.ginger.provider.format.JodaTimeUtils.java

License:Apache License

private static DateTimeFormatter createJodaDateFormatter(FormatType formatType, DateFormatStyle formatStyle) {
    switch (formatType) {
    case TIME://w  w  w  .  j a va 2s .  c  o  m
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortTime();
        case MEDIUM:
            return DateTimeFormat.mediumTime();
        case LONG:
            return DateTimeFormat.longTime();
        case FULL:
            return DateTimeFormat.fullTime();
        case DEFAULT:
            return ISODateTimeFormat.time();
        }
    case DATE:
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortDate();
        case MEDIUM:
            return DateTimeFormat.mediumDate();
        case LONG:
            return DateTimeFormat.longDate();
        case FULL:
            return DateTimeFormat.fullDate();
        case DEFAULT:
            return ISODateTimeFormat.date();
        }
    case DATETIME:
        switch (formatStyle) {
        case SHORT:
            return DateTimeFormat.shortDateTime();
        case MEDIUM:
            return DateTimeFormat.mediumDateTime();
        case LONG:
            return DateTimeFormat.longDateTime();
        case FULL:
            return DateTimeFormat.fullDateTime();
        case DEFAULT:
            return ISODateTimeFormat.dateTime();
        }
    }

    throw new IllegalArgumentException();
}

From source file:de.javakaffee.msm.bench.JodaTimePage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 * /*from   w ww  .j a va2s .co m*/
 * @param parameters
 *            Page parameters
 */
public JodaTimePage(final PageParameters parameters) {

    setStatelessHint(false);

    // Add the simplest type of label
    add(new Label("message", "A statefull page, just click and watch the time running."));

    _dateTime = new DateTime();

    final Link<String> link = new Link<String>("link", new Model<String>("forward")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            LOG.info("Link clicked.");
            _dateTime = _dateTime.plusDays(1);
        }

    };

    link.add(new Label("linkLabel", new Model<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return "Now it's " + _dateTime.toString(DateTimeFormat.fullDate()) + "! (i'm " + JodaTimePage.this
                    + ")";
        }

    }));

    add(link);

    // TODO Add your page's components here
}

From source file:org.emonocot.harvest.media.ImageMetadataExtractorImpl.java

License:Open Source License

public ImageMetadataExtractorImpl() {

    dateTimeFormatters.add(ISODateTimeFormat.dateTimeParser());
    dateTimeFormatters.add(DateTimeFormat.fullDate());
    dateTimeFormatters.add(DateTimeFormat.fullDateTime());
    dateTimeFormatters.add(DateTimeFormat.shortDate());
    dateTimeFormatters.add(DateTimeFormat.shortDateTime());
    dateTimeFormatters.add(DateTimeFormat.mediumDate());
    dateTimeFormatters.add(DateTimeFormat.mediumDateTime());

}

From source file:org.gdg.frisbee.android.event.EventOverviewFragment.java

License:Apache License

private String formatDate(EventFullDetails eventFullDetails) {

    DateTimeFormatter fmt = DateTimeFormat.fullDate();
    // TODO check whether this is a multi day event
    return fmt.print(eventFullDetails.getStart());
}