Example usage for com.google.gwt.i18n.client DateTimeFormat getMediumDateFormat

List of usage examples for com.google.gwt.i18n.client DateTimeFormat getMediumDateFormat

Introduction

In this page you can find the example usage for com.google.gwt.i18n.client DateTimeFormat getMediumDateFormat.

Prototype

@Deprecated
public static DateTimeFormat getMediumDateFormat() 

Source Link

Document

Retrieve the DateTimeFormat object for medium date format.

Usage

From source file:com.bradrydzewski.gwtgantt.gantt.GanttChartPresenter.java

License:Open Source License

@SuppressWarnings("deprecation")
protected void renderBackground() {

    Date date = (Date) start.clone();

    int diff = DateUtil.differenceInDays(start, finish);
    int weeks = (int) Math.ceil(diff / 7);

    // FOR EACH WEEK
    for (int i = 0; i < weeks; i++) {

        //TODO: Remove reference to DateTimeFormat, which requires GWT Test Case
        Date firstDayOfWeek = DateUtil.getFirstDayOfWeek(date);
        String topTimescaleString = DateTimeFormat.getMediumDateFormat().format(firstDayOfWeek);

        //ADD WEEK PANEL
        Rectangle weekHeaderBounds = new Rectangle(ROW1_WIDTH_OFFSET * i, 0, ROW1_WIDTH, 25);
        view.renderTopTimescaleCell(weekHeaderBounds, topTimescaleString);

        // ADD 7 DAYS PER WEEK
        for (int d = 0; d < DateUtil.DAYS_PER_WEEK; d++) {
            //ADD DAY PANEL
            Date weekDay = DateUtil.addDays(date, d);
            int width = ROW2_WIDTH;
            int height = 24;
            int left = (ROW1_WIDTH_OFFSET * i) + (ROW2_WIDTH_OFFSET * d);
            int top = 0;
            Rectangle bottomTimescaleBounds = new Rectangle(left, top, width, height);
            String bottomTimescaleString = weekDay.getDate() + "";
            view.renderBottomTimescaleCell(bottomTimescaleBounds, bottomTimescaleString);

            if (d == SATURDAY || d == SUNDAY) {
                //ADD BACKGROUND FOR SAT, SUND
                int colTop = 0;
                int colLeft = (ROW1_WIDTH_OFFSET * i) + (ROW2_WIDTH_OFFSET * d);
                int colWidth = 38;
                int colHeight = -1; //not used... 100% defined by style
                Rectangle colBounds = new Rectangle(colLeft, colTop, colWidth, colHeight);
                view.renderColumn(colBounds, d);
            }//from w ww. ja  v a 2  s .c om
        }

        date = DateUtil.addDays(date, DateUtil.DAYS_PER_WEEK);
    }
}

From source file:com.dingziran.effective.client.content.widgets.CwDatePicker.java

License:Apache License

/**
 * Constructor./*from w  w  w . j  av a2  s .c  o  m*/
 *
 * @param constants the constants
 */
public CwDatePicker(CwConstants constants) {
    super(constants.cwDatePickerName(), constants.cwDatePickerDescription());
    this.constants = constants;
    view = new ContentWidgetView(hasMargins(), hasScrollableContent());
    view.setName(getName());
    view.setDescription(getDescription());
    setWidget(view);
    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getMediumDateFormat().format(date);
            text.setText(dateString);
        }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);

    // Create a DateBox
    DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat();
    DateBox dateBox = new DateBox();
    dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));

    // Combine the widgets into a panel and return them
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(new HTML(constants.cwDatePickerLabel()));
    vPanel.add(text);
    vPanel.add(datePicker);
    vPanel.add(new HTML(constants.cwDatePickerBoxLabel()));
    vPanel.add(dateBox);
    view.setExample(vPanel);
}

From source file:com.google.gwt.examples.DatePickerExample.java

License:Apache License

public void onModuleLoad() {
    // Create a date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getMediumDateFormat().format(date);
            text.setText(dateString);//from  ww w  . j av a 2s .co m
        }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);

    // Add the widgets to the page
    RootPanel.get().add(text);
    RootPanel.get().add(datePicker);
}

From source file:com.google.gwt.sample.expenses.client.MobileExpenseDetails.java

License:Apache License

public void show(ExpenseProxy expense) {
    this.expense = expense;

    @SuppressWarnings("deprecation")
    DateTimeFormat formatter = DateTimeFormat.getMediumDateFormat();

    Approval approval = Approval.from(expense.getApproval());
    nameText.setInnerText(expense.getDescription());
    dateText.setInnerText(formatter.format(expense.getCreated()));
    categoryText.setInnerText(expense.getCategory());
    priceText.setInnerText(ExpensesMobile.formatCurrency(expense.getAmount()));
    approvalText.setInnerHTML(Approval.BLANK.equals(approval) ? "Awaiting Review" : approval.getText());
    approvalText.getStyle().setColor(approval.getColor());

    reasonText.setInnerText(expense.getReasonDenied());
    if (Approval.DENIED.equals(approval)) {
        // Show the reason denied.
        reasonRow.getStyle().clearDisplay();
    } else {/*w  ww .j  av  a2s .co m*/
        // Hide the reason denied.
        reasonRow.getStyle().setDisplay(Display.NONE);
    }
}

From source file:com.google.gwt.sample.i18n.client.DateTimeFormatExampleController.java

License:Apache License

@Override
protected String doGetPattern(String patternKey) {
    // Date + Time
    if ("fullDateTime".equals(patternKey)) {
        return DateTimeFormat.getFullDateTimeFormat().getPattern();
    }//from  w w  w . j  a va2  s  . c o  m

    if ("longDateTime".equals(patternKey)) {
        return DateTimeFormat.getLongDateTimeFormat().getPattern();
    }

    if ("mediumDateTime".equals(patternKey)) {
        return DateTimeFormat.getMediumDateTimeFormat().getPattern();
    }

    if ("shortDateTime".equals(patternKey)) {
        return DateTimeFormat.getShortDateTimeFormat().getPattern();
    }

    // Date only
    if ("fullDate".equals(patternKey)) {
        return DateTimeFormat.getFullDateFormat().getPattern();
    }

    if ("longDate".equals(patternKey)) {
        return DateTimeFormat.getLongDateFormat().getPattern();
    }

    if ("mediumDate".equals(patternKey)) {
        return DateTimeFormat.getMediumDateFormat().getPattern();
    }

    if ("shortDate".equals(patternKey)) {
        return DateTimeFormat.getShortDateFormat().getPattern();
    }

    // Time only
    if ("fullTime".equals(patternKey)) {
        return DateTimeFormat.getFullTimeFormat().getPattern();
    }

    if ("longTime".equals(patternKey)) {
        return DateTimeFormat.getLongTimeFormat().getPattern();
    }

    if ("mediumTime".equals(patternKey)) {
        return DateTimeFormat.getMediumTimeFormat().getPattern();
    }

    if ("shortTime".equals(patternKey)) {
        return DateTimeFormat.getShortTimeFormat().getPattern();
    }

    throw new IllegalArgumentException("Unknown pattern key '" + patternKey + "'");
}

From source file:com.google.gwt.sample.showcase.client.content.widgets.CwDatePicker.java

License:Apache License

/**
 * Initialize this example./*from  w  ww.ja va 2 s  . c o m*/
 */
@SuppressWarnings("deprecation")
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getMediumDateFormat().format(date);
            text.setText(dateString);
        }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);

    // Create a DateBox
    DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat();
    DateBox dateBox = new DateBox();
    dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));

    // Combine the widgets into a panel and return them
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(new HTML(constants.cwDatePickerLabel()));
    vPanel.add(text);
    vPanel.add(datePicker);
    vPanel.add(new HTML(constants.cwDatePickerBoxLabel()));
    vPanel.add(dateBox);
    return vPanel;
}

From source file:com.googlecode.hmvc4gwt.example.hmvcblog.frontend.blog.client.blog.blogentry.BlogEntryController.java

License:Open Source License

public void initView() {

    Label labelDate = new Label(
            DateTimeFormat.getMediumDateFormat().format(getModel().getBlogEntryDTO().getDate()));
    getView().setLabelDate(labelDate);/*from  w w w  .  j  a v  a2s . c  om*/

    Label labelTitle = new Label(getModel().getBlogEntryDTO().getTitle());
    getView().setLabelTitle(labelTitle);

    HorizontalPanel horizontalPanelTitle = new HorizontalPanel();
    getView().setHorizontalPanelTitle(horizontalPanelTitle);

    Label labelText = new Label(getModel().getBlogEntryDTO().getText());
    getView().setLabelText(labelText);

    VerticalPanel verticalPanelContainer = new VerticalPanel();
    verticalPanelContainer.setStylePrimaryName("blogEntry");
    getView().setVerticalPanelContainer(verticalPanelContainer);

    /*
     * build view
     */
    horizontalPanelTitle.add(labelDate);
    horizontalPanelTitle.add(labelTitle);

    verticalPanelContainer.add(horizontalPanelTitle);
    verticalPanelContainer.add(labelText);

}

From source file:fr.aliasource.webmail.client.reader.invitation.InvitationPanel.java

License:GNU General Public License

private VerticalPanel fillAgendaPanel() {
    agendaPanel = new VerticalPanel();
    agendaPanel.setStyleName("agendaPanel");
    agendaPanel.setBorderWidth(1);/*from  w ww .  j a  v a2s  .com*/
    if (invitationInfo.getEvent().getDtStart() != null) {
        Date when = invitationInfo.getEvent().getDtStart();
        DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat();
        HTML day = new HTML(strings.invitationDay(dtf.format(when)));
        day.setStyleName("invitationDay");
        agendaPanel.add(day);
    }

    for (SimpleEvent sEvent : invitationInfo.getEventOfDay()) {
        String sStart = "";
        if (sEvent.isAllDay()) {
            sStart = strings.eventAllDay();
        } else if (sEvent.getStart() != null) {
            DateTimeFormat dtfStart = DateTimeFormat.getShortTimeFormat();
            sStart = dtfStart.format(sEvent.getStart());
        }
        InvitationAgendaLine line = new InvitationAgendaLine(sStart, sEvent.getTitle());
        agendaPanel.add(line);

    }

    Anchor a = new Anchor(strings.invitationGoToCalendar());
    a.setHref(invitationInfo.getCalendarUrl());
    a.setTarget("_blank");
    agendaPanel.add(a);

    return agendaPanel;
}

From source file:gwtquery.plugins.draggable.client.GWTIntegrationSample.java

License:Apache License

/**
 * Create a Date picker. The code comes from the GWT show case :
 * http://gwt.google.com/samples/Showcase/Showcase.html#!CwDatePicker@
 *
 * @return//w  w w  . j ava2s . c  o m
 */
private VerticalPanel createDatePanel() {
    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
        public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getMediumDateFormat().format(date);
            text.setText(dateString);
        }
    });

    // Set the default value
    datePicker.setValue(new Date(), true);

    // Combine the widgets into a panel and return them
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(new HTML("Permanent DatePicker:"));
    vPanel.add(text);
    vPanel.add(datePicker);
    return vPanel;

}

From source file:java.text.DateFormat.java

License:Apache License

public final static DateFormat getDateInstance() {
    return new SimpleDateFormat(DateTimeFormat.getMediumDateFormat());
}