Java Code Examples for com.google.gwt.i18n.client.DateTimeFormat#format()

The following examples show how to use com.google.gwt.i18n.client.DateTimeFormat#format() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBController.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/**
 * Get dataset panel show values .
 * 
 * @param dataset
 * @param isUpdate
 * @return  Data panel show value array
 */
public static String[] getDatasetPanelValue(final Dataset dataset, boolean isUpdate) {
	String[] values = new String[7];
	Date dateNow = new Date();
	DateTimeFormat dateFormat = DateTimeFormat
			.getFormat("yyyy-MM-dd KK:mm:ss a");
	values[4] = dateFormat.format(dateNow);
	double version = 0;
	if ((!dataset.getVersion().contains("n"))&&isUpdate){
		version = Double.parseDouble(dataset.getVersion()) + 0.1;
	}else version = Double.parseDouble(dataset.getVersion());     
	values[3] = NumberFormat.
			getFormat("#0.0").format(version);

	values[1] = null;
	String TypeString = dataset.getContenttype();
	if (TypeString == null || TypeString.equals("") || "General".equals(TypeString)) values[2] = "General/CSV/TSV/JSON";
	else if ("TSV".equals(TypeString)) values[2] = "TSV/General/CSV/JSON";
	else if ("CSV".equals(TypeString)) values[2] = "CSV/General/TSV/JSON";
	else values[2] = "JSON/General/TSV/CSV";
	values[0] = dataset.getName();
	values[5] = AppController.email;
	values[6] = dataset.getDescription();
	return values;
}
 
Example 2
Source File: GanttDateTimeService.java    From gantt with Apache License 2.0 6 votes vote down vote up
public String formatDate(Date date, String formatStr, TimeZone timeZone) {
    /*
     * Format month and day names separately when locale for the
     * DateTimeService is not the same as the browser locale
     */
    formatStr = formatMonthNames(date, formatStr);
    formatStr = formatDayNames(date, formatStr);

    // Format uses the browser locale
    DateTimeFormat format = DateTimeFormat.getFormat(formatStr);

    if (timeZone != null) {
        return format.format(date, timeZone);
    } else {
        return format.format(date, gmt);
    }
}
 
Example 3
Source File: Header.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
private Label getCopyrightLink() {

        DateTimeFormat dateFormatter = DateTimeFormat.getFormat("yyyy");
		String year = dateFormatter.format(new Date());

        Label copyright = getHeaderLinkLabel("© 52°North, GmbH " + year);
        copyright.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				String url = "http://www.52north.org";
                Window.open(url, "_blank", "");
			}
		});
		return copyright;
	}
 
Example 4
Source File: ReportList.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor of ReportWidgets
 * @param report GalleryAppReport
 */
private ReportWidgets(final GalleryAppReport report) {

  reportTextLabel = new Label(report.getReportText());
  reportTextLabel.addStyleName("ode-ProjectNameLabel");
  reportTextLabel.setWordWrap(true);
  reportTextLabel.setWidth("200px");

  appLabel = new Label(report.getApp().getTitle());
  appLabel.addStyleName("primary-link");

  DateTimeFormat dateTimeFormat = DateTimeFormat.getMediumDateTimeFormat();
  Date dateCreated = new Date(report.getTimeStamp());
  dateCreatedLabel = new Label(dateTimeFormat.format(dateCreated));

  appAuthorlabel = new Label(report.getOffender().getUserName());
  appAuthorlabel.addStyleName("primary-link");

  reporterLabel = new Label(report.getReporter().getUserName());
  reporterLabel.addStyleName("primary-link");

  sendEmailButton = new Button(MESSAGES.buttonSendEmail());

  deactiveAppButton = new Button(MESSAGES.labelDeactivateApp());

  markAsResolvedButton = new Button(MESSAGES.labelmarkAsResolved());

  seeAllActions = new Button(MESSAGES.labelSeeAllActions());
}
 
Example 5
Source File: ISO8601.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Format date with format "YYYY-MM-DDThh:mm:ss.SSSTZD"
 */
public static String formatExtended(Date value) {
	if (value == null) {
		return null;
	} else {
		DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
		return dtf.format(value);
	}
}
 
Example 6
Source File: ISO8601.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Format date with format "yyyyMMddHHmmss"
 */
public static String formatBasic(Date value) {
	if (value == null) {
		return null;
	} else {
		DateTimeFormat dtf = DateTimeFormat.getFormat(BASIC_PATTER);
		return dtf.format(value);
	}
}
 
Example 7
Source File: UTCTimeBoxImplShared.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
/**
 * Formats the value provided with the specified DateTimeFormat
 */
protected static final String formatUsingFormat(Long value, DateTimeFormat fmt) {
    if (value == null) {
        return "";
    }
    else {
        // midnight GMT
        Date date = new Date(0);
        // offset by timezone and value
        date.setTime(UTCDateBox.timezoneOffsetMillis(date) + value.longValue());
        // format it
        return fmt.format(date);
    }
}
 
Example 8
Source File: UTCDateBoxImplHtml5.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
/**
 * Formats the supplied value using the specified DateTimeFormat.
 * 
 * @return "" if the value is null
 */
private String long2string(Long value, DateTimeFormat fmt) {
    // for html5 inputs, use "" for no value
    if (value == null) return "";
    Date date = UTCDateBox.utc2date(value);
    return date != null ? fmt.format(date) : null;
}
 
Example 9
Source File: DBController.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * Get program panel show values .
 * 
 * @param program
 * @param isUpdate
 * @return  Program panel show value array
 */
public static String[] getProgramPanelValue(final Program program, boolean isUpdate) {

	final String[] values = new String[10];
	int i = 0;
	values[i++] = program.getName();

	//for category
	values[i++] = null;
	String TypeString = program.getType();
	logger.info(TypeString.toLowerCase());
	if ("单机".equals(TypeString.toLowerCase()) || "standalone".equals(TypeString.toLowerCase()))
		values[i] = Constants.studioUIMsg.standalone() + "/" + Constants.studioUIMsg.distributed()+"/ETL"+"/Tensorflow";
	if ("spark".equals(TypeString) || "分布式".equals(TypeString) ||TypeString.equals("distributed")||TypeString.toLowerCase().equals("distributed")) {
		values[i] = Constants.studioUIMsg.distributed() + "/" + Constants.studioUIMsg.standalone() + "/ETL"+"/Tensorflow";
	}
	if ("etl".equals(TypeString))
		values[i] = "ETL/"+Constants.studioUIMsg.distributed() + "/" + Constants.studioUIMsg.standalone()+"/Tensorflow";
	if("tensorflow".equals(TypeString))
		values[i] = "Tensorflow/"+Constants.studioUIMsg.distributed() + "/" + Constants.studioUIMsg.standalone()+"/ETL";

	i ++;

	if( program.getProgramable() ) values[i] = Constants.studioUIMsg.yes() + "/" + Constants.studioUIMsg.no();
	else values[i] = Constants.studioUIMsg.no() + "/" + Constants.studioUIMsg.yes();
	i ++;

	boolean deterministic = program.getIsdeterministic();
	if (deterministic) values[i] = Constants.studioUIMsg.yes() + "/" + Constants.studioUIMsg.no();
	else values[i] = Constants.studioUIMsg.no() + "/" + Constants.studioUIMsg.yes();
	i ++;

	double version = 0;
	if ((!program.getVersion().contains("n"))&&isUpdate){
		version = Double.parseDouble(program.getVersion()) + 0.1;
	}else version = Double.parseDouble(program.getVersion());

	values[i] = NumberFormat.getFormat("#0.0").format(version);
	i ++;

	Date dateNow = new Date();
	DateTimeFormat dateFormat = DateTimeFormat
			.getFormat("yyyy-MM-dd KK:mm:ss a");
	values[i] = dateFormat.format(dateNow);
	i ++;

	values[i++] = AppController.email;
	values[i++] = program.getDescription();
	values[i++] = program.getCommandline();

	String tensorflowMode = program.getTensorflowMode();
	if("单机".equals(tensorflowMode) || "standalone".equals(tensorflowMode))
		values[i] = Constants.studioUIMsg.standalone()+"/"+Constants.studioUIMsg.modelDistributed()+"/"+Constants.studioUIMsg.dataDistributed();
	else if("模型分布".equals(tensorflowMode) || "model distributed".equals(tensorflowMode))
		values[i] = Constants.studioUIMsg.modelDistributed()+"/"+Constants.studioUIMsg.standalone()+"/"+Constants.studioUIMsg.dataDistributed();
	else if("数据分布".equals(tensorflowMode) || "data distributed".equals(tensorflowMode))
		values[i] = Constants.studioUIMsg.dataDistributed()+"/"+Constants.studioUIMsg.standalone()+"/"+Constants.studioUIMsg.modelDistributed();
	else 
		values[i]= Constants.studioUIMsg.standalone()+"/"+Constants.studioUIMsg.modelDistributed()+"/"+Constants.studioUIMsg.dataDistributed();

	return values;
}
 
Example 10
Source File: GalleryGuiFactory.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Creates list of comments in the app page.
 * @param comments: list of returned gallery comments from callback.
 * @param container: the GUI panel where comments will reside.
 */
public void generateAppPageComments(List<GalleryComment> comments, FlowPanel container) {
  container.clear();  // so don't show previous listing
  if (comments == null) {
    Label noComments = new Label("This app does not have any comments yet.");
    noComments.addStyleName("comment-nope");
    container.add(noComments);
    return;
  }

  for ( GalleryComment c : comments) {
    FlowPanel commentItem = new FlowPanel();
    FlowPanel commentPerson = new FlowPanel();
    FlowPanel commentMeta = new FlowPanel();
    FlowPanel commentContent = new FlowPanel();

    // Add commentPerson, default avatar for now
    Image cPerson = new Image();
    cPerson.setUrl(PERSON_URL);
    commentPerson.add(cPerson);
    commentPerson.addStyleName("comment-person");
    commentItem.add(commentPerson);

    // Add commentContent
    Label cAuthor = new Label(c.getUserName());
    cAuthor.addStyleName("comment-author");
    commentMeta.add(cAuthor);

    Date commentDate = new Date(c.getTimeStamp());
    DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy/MM/dd hh:mm:ss a");
    Label cDate = new Label(" on " + dateFormat.format(commentDate));
    cDate.addStyleName("comment-date");
    commentMeta.add(cDate);

    commentMeta.addStyleName("comment-meta");
    commentContent.add(commentMeta);

    Label cText = new Label(c.getComment());
    cText.addStyleName("comment-text");
    commentContent.add(cText);

    commentContent.addStyleName("comment-content");
    commentItem.add(commentContent);

    commentItem.addStyleName("comment-item");
    commentItem.addStyleName("clearfix");
    container.add(commentItem);
  }
}
 
Example 11
Source File: TopicScrollTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addRow
 *
 * @param topic
 */
public void addRow(final GWTForumTopic topic) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);

	// Topic column
	VerticalPanel topicPanel = new VerticalPanel();
	Anchor anchor = new Anchor();
	anchor.setHTML("<b>" + topic.getTitle() + "</b>");
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			controller.refreshPosts(topic.getId(), topic.getTitle());
		}
	});
	anchor.setStyleName("okm-Forum-Topic");
	HorizontalPanel topicUser = new HorizontalPanel();
	HTML by = new HTML(GeneralComunicator.i18nExtension("forum.user.by") + "&nbsp;");
	by.setStyleName("okm-Forum-Gray");
	topicUser.add(by);
	HTML user = new HTML(topic.getUser());
	user.setStyleName("okm-Forum-User");
	topicUser.add(user);
	HTML separator = new HTML("&nbsp;&raquo;&nbsp;");
	separator.setStyleName("okm-Forum-Gray");
	topicUser.add(separator);
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18n("general.date.pattern"));
	HTML date = new HTML(dtf.format(topic.getDate()));
	date.setStyleName("okm-Forum-Gray");
	topicUser.add(date);
	topicPanel.add(anchor);
	topicPanel.add(topicUser);
	dataTable.setWidget(rows, 0, topicPanel);

	// Reply column
	dataTable.setHTML(rows, 1, "" + topic.getReplies());

	// View column
	dataTable.setHTML(rows, 2, "" + topic.getViews());

	// Last post column
	VerticalPanel lastPost = new VerticalPanel();
	HorizontalPanel lastUserTopic = new HorizontalPanel();
	HTML by2 = new HTML(GeneralComunicator.i18nExtension("forum.user.by") + "&nbsp;");
	by2.setStyleName("okm-Forum-Gray");
	lastUserTopic.add(by2);
	HTML lastUser = new HTML(topic.getLastPostUser());
	lastUser.setStyleName("okm-Forum-User");
	lastUserTopic.add(lastUser);
	lastPost.add(lastUserTopic);
	dtf = DateTimeFormat.getFormat(GeneralComunicator.i18n("general.date.pattern"));
	HTML date2 = new HTML(dtf.format(topic.getLastPostDate()));
	date2.setStyleName("okm-Forum-Gray");
	lastPost.add(date2);
	dataTable.setWidget(rows, 3, lastPost);

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVerticalAlignment(rows, 0, HasAlignment.ALIGN_MIDDLE);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setVerticalAlignment(rows, 1, HasAlignment.ALIGN_MIDDLE);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setVerticalAlignment(rows, 2, HasAlignment.ALIGN_MIDDLE);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVerticalAlignment(rows, 3, HasAlignment.ALIGN_MIDDLE);
}
 
Example 12
Source File: DisplayerGwtFormatter.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
@Override
public String formatDate(String pattern, Date d) {
    DateTimeFormat df = getDateFormat(pattern);
    return df.format(d);
}