當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeFormat.format方法代碼示例

本文整理匯總了Java中com.google.gwt.i18n.client.DateTimeFormat.format方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeFormat.format方法的具體用法?Java DateTimeFormat.format怎麽用?Java DateTimeFormat.format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.i18n.client.DateTimeFormat的用法示例。


在下文中一共展示了DateTimeFormat.format方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDatasetPanelValue

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * 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 ("General".equals(TypeString)) values[2] = "General/TSV/CSV";
	if ("TSV".equals(TypeString)) values[2] = "TSV/General/TSV";
	if ("CSV".equals(TypeString)) values[2] = "CSV/General/TSV";
	else values[2] = "General/TSV/CSV";
	values[0] = dataset.getName();
	values[5] = AppController.email;
	values[6] = dataset.getDescription();
	return values;
}
 
開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:32,代碼來源:DBController.java

示例2: onDateSubmit

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@Override
public void onDateSubmit(Date startDate, Date endDate, String account) {

    DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");

    if (startDate.getTime() > endDate.getTime()) {

        MaterialToast.fireToast("Whoops! Invalid date range.", 1000);
    } else {
        String fromDate = fmt.format(startDate);
        String toDate = fmt.format(endDate);
        String dateRange = fromDate + toDate;

        clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account));
    }

}
 
開發者ID:WSDOT,項目名稱:social-analytics,代碼行數:18,代碼來源:AnalyticsActivity.java

示例3: addNewFieldValuePair

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
protected void addNewFieldValuePair( final FlowPanel content, final String fieldName,
		   						   final Date dateValue, final boolean addEndCommaDelimiter ) {
	final Label fieldLabel = new Label( fieldName );
	fieldLabel.setStyleName( CommonResourcesContainer.USER_DIALOG_REGULAR_FIELD_STYLE );
	final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( PredefinedFormat.DATE_TIME_SHORT );
	final Label dateTimeLabel = new Label( dateTimeFormat.format( dateValue ) );
	dateTimeLabel.setStyleName( CommonResourcesContainer.CONST_FIELD_VALUE_DEFAULT_STYLE_NAME );
	final int width = ( dateTimeLabel.getOffsetWidth() == 0 ? DEFAULT_PROGRESS_BAR_WIDTH_PIXELS : dateTimeLabel.getOffsetWidth() );
	DateOldProgressBarUI progressBarUI= new DateOldProgressBarUI( width, DEFAULT_PROGRESS_BAR_HEIGHT_PIXELS, dateValue );
	
	//If there are replies to this message
	VerticalPanel dateTimePanel = new VerticalPanel();
	dateTimePanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
	dateTimePanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_BOTTOM );
	dateTimePanel.add( dateTimeLabel );
	dateTimePanel.add( progressBarUI );
	
	//Add the widgets to the panel
	addNewFieldValuePair( content, fieldLabel, dateTimePanel, addEndCommaDelimiter );
}
 
開發者ID:ivan-zapreev,項目名稱:x-cure-chat,代碼行數:21,代碼來源:ForumMessageWidget.java

示例4: getRelative

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * 
 * @param date
 * @return
 */
private static String getRelative(Date date) {
	DateTimeFormat displayDateFormat = DateTimeFormat.getFormat("MMMM d, yyyy h:mm a");	
	int delta = 0;

	try {
		Date relativeDate = new Date();
		delta = (int)((relativeDate.getTime() - date.getTime()) / 1000); // convert to seconds
		if (delta < 60) {
			return delta + " seconds ago";
		} else if (delta < 120) {
			return "1 minute ago";
		} else if (delta < (60*60)) {
			return Integer.toString(delta / 60) + " minutes ago";
		} else if (delta < (120*60)) {
			return "1 hour ago";
		} else if (delta < (24*60*60)) {
			return Integer.toString(delta / 3600) + " hours ago";
		} else {
			return displayDateFormat.format(date);
		}
	} catch (Exception e) {
		return "Unavailable";
	}		

}
 
開發者ID:waynedyck,項目名稱:mgwt-traffic-flow,代碼行數:31,代碼來源:ParserUtils.java

示例5: ReportWidgets

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * 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());
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:33,代碼來源:ReportList.java

示例6: formatExtended

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:12,代碼來源:ISO8601.java

示例7: formatBasic

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:12,代碼來源:ISO8601.java

示例8: getRetweets

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
public static void getRetweets(String account, Date start, Date end, final MaterialCollection list, final String listType){

        list.clear();

        DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");
        String startDate = fmt.format(start);
        String endDate = fmt.format(end);
        String screenName = account;

        String url = Consts.HOST_URL + "/summary/statuses/retweets/" + listType + "/" + screenName + startDate + endDate;

        loader.setVisible(true);

        JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
        // Set timeout for 30 seconds (30000 milliseconds)
        jsonp.setTimeout(30000);
        jsonp.requestObject(url, new AsyncCallback<Mention>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Failure: " + caught.getMessage());
                loader.setVisible(false);
            }

            @Override
            public void onSuccess(Mention mention) {
                if (mention.getMentions() != null) {
                    list.clear();
                    updateRetweetList(mention.getMentions(), list, listType);
                    loader.setVisible(false);
                }
            }
        });
    }
 
開發者ID:WSDOT,項目名稱:social-analytics,代碼行數:35,代碼來源:RankingView.java

示例9: getLikes

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
public static void getLikes(String account, Date start, Date end, final MaterialCollection list, final String listType){

        list.clear();

        DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");
        String startDate = fmt.format(start);
        String endDate = fmt.format(end);
        String screenName = account;

        String url = Consts.HOST_URL + "/summary/statuses/favorites/" + listType + "/" + screenName + startDate + endDate;

        loader.setVisible(true);

        JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
        // Set timeout for 30 seconds (30000 milliseconds)
        jsonp.setTimeout(30000);
        jsonp.requestObject(url, new AsyncCallback<Mention>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Failure: " + caught.getMessage());
                loader.setVisible(false);
            }

            @Override
            public void onSuccess(Mention mention) {
                if (mention.getMentions() != null) {
                    list.clear();
                    updateLikesList(mention.getMentions(), list, listType);
                    loader.setVisible(false);
                }
            }
        });
    }
 
開發者ID:WSDOT,項目名稱:social-analytics,代碼行數:35,代碼來源:RankingView.java

示例10: onSearch

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@UiHandler("searchBtn")
void onSearch(ClickEvent e){

    if (advSearchTextBox.getText().equalsIgnoreCase("")){
        advSearchTextBox.setText(" ");
    }

    DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");

    String endDate = null;
    String startDate = null;

    if (searchdpStart.getDate() != null) {
        startDate = fmt.format(searchdpStart.getDate());
    }

    if (searchdpEnd.getDate() != null) {
        endDate = fmt.format(searchdpEnd.getDate());
    }

    String account = searchAccountPicker.getSelectedItemText();
    int searchType = Integer.valueOf(searchTypePicker.getSelectedValue());
    String searchTerm = advSearchTextBox.getText();

    int media = (mediaOnly.getValue() ? 1 : 0);

    SearchEvent searchEvent = new SearchEvent(searchTerm, searchType, account, media, startDate, endDate);

    this.clientFactory.getEventBus().fireEvent(searchEvent);
    advSearch.closeModal();

}
 
開發者ID:WSDOT,項目名稱:social-analytics,代碼行數:33,代碼來源:AdvSearchView.java

示例11: onDateSubmit

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@EventHandler
void onDateSubmit(DateSubmitEvent event){
    DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");
    pageNum = 1;
    currentAccount = event.getAccount();
    startDate = fmt.format(event.getStartDate());
    endDate = fmt.format(event.getEndDate());
    updateTweets(startDate, endDate, event.getAccount());
}
 
開發者ID:WSDOT,項目名稱:social-analytics,代碼行數:10,代碼來源:TweetsView.java

示例12: addMessage

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
public void addMessage(ConsoleLogType code, String content) {

		Date date = new Date();
		DateTimeFormat dtf = DateTimeFormat.getFormat("HH:mm:ss:SS");

		String output = "";
		output += "<span style=\"color:grey\">"
				+ dtf.format(date, TimeZone.createTimeZone(this.getClientOffsetTimeZone())) + "</span> ";

		switch (code) {
		case ERROR:
			output += "<span style=\"color:red\">ERROR</span> ";
			break;
		case SUCCESS:
			output += "<span style=\"color:green\">SUCCESS</span> ";
			break;
		case INFO:
			output += "<span style=\"color:grey\">INFO</span> ";
			break;
		case WARNING:
			output += "<span style=\"color:orange\">WARNING</span> ";
			break;
		case ACTION:
			output += "<span style=\"color: #3F51B5;\">ACTION</span> ";
		default:
			break;
		}

		output += content;

		Element div = DOM.createElement("div");
		div.setInnerHTML(output);
		this.JSNI_appendChild(this.element, div);
		this.JSNI_updatePosition(this.element);
	}
 
開發者ID:ls1intum,項目名稱:MIBO-IDE,代碼行數:36,代碼來源:WCConsoleArea.java

示例13: Top10UserFileWidget

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * The basic constructor
 * @param parentDialog the reference to the parent dialog or null if none
 * @param fileDescriptors the list of the users' profile files to browse through 
 * @param fileIndex the index of the file we create this preview widget for
 */
public Top10UserFileWidget( final DialogBox parentDialog, final List<ShortUserFileDescriptor> fileDescriptors, final int fileIndex ) {
	//Store the data
	this.parentDialog = parentDialog;
	this.fileDescr = fileDescriptors.get( fileIndex );
	
	//Initialize and fill out the main panel
	mainPanel = new VerticalPanel();
	mainPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
	
	//Initialize the image 
	previewImage = constructThumbnailImage( fileDescriptors, fileIndex );
	
	//Initialize the upload date panel
	final HorizontalPanel uploadDatePanel = new HorizontalPanel();
	uploadDatePanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_BOTTOM );
	//Add the image
	uploadDatePanel.add( new Image( ServerSideAccessManager.USER_INFO_RELATED_IMAGES_LOCATION +
			  			 ServerSideAccessManager.SERVER_CONTEXT_DELIMITER + "uploaded.png" ) );
	uploadDatePanel.add( new HTML("&nbsp;") );
	//Add the date label
	{
		final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( PredefinedFormat.DATE_TIME_SHORT );
		final Label uploadDateLabel = new Label( dateTimeFormat.format( fileDescr.uploadDate ) );
		uploadDateLabel.setStyleName( CommonResourcesContainer.TOP_TEN_USER_FILE_UPLOAD_DATE_STYLE );
		uploadDatePanel.add( uploadDateLabel );
	}
	
	//Initialize the user name label
	userNameAvatar = new UserAvatarWidget( fileDescr.ownerID, fileDescr.ownerLoginName );
	
	mainPanel.add( previewImage );
	mainPanel.add( uploadDatePanel );
	mainPanel.add( userNameAvatar );
	
	//Initialize the composite
	initWidget(mainPanel);
}
 
開發者ID:ivan-zapreev,項目名稱:x-cure-chat,代碼行數:44,代碼來源:Top10UserFileWidget.java

示例14: setDateLabelValue

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * This method sets the Date value label. Calls the setLabelValue method.
 * @param label the label to set value to
 * @param date the date value to set
 */
protected void setDateLabelValue( Label label, Date date ) {
	String dateStr = null;
	if( date != null ) {
		final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( PredefinedFormat.DATE_TIME_SHORT );
		dateStr = dateTimeFormat.format( date );
	}
	setLabelValue( null, label, dateStr );
}
 
開發者ID:ivan-zapreev,項目名稱:x-cure-chat,代碼行數:14,代碼來源:ActionGridDialog.java

示例15: appendMessageContent

import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
 * Allows to append the given message data to the current message UI.
 * WARNING: This method just appends the data, it does not check if this is allowed or not!
 * WARNING: Do not append a new message data to a minimized message or to a message
 * of a different type or with different recipients!
 * @param message the message data to be appended
 * @param visibleUsers the list of visible users
 * @param roomID the id of the room
 */
public void appendMessageContent( final ChatMessage message,
		   						  final Map<Integer, ShortUserData> visibleUsers,
		   						  final int roomID ) {
	if( message != null ) {
		//If this is a status change message then add a delimiter
		//and remove the click handler in case the status change
		//is for another user
		if( message.messageType == ChatMessage.Types.USER_STATUS_CHAGE_INFO_MESSAGE_TYPE ) {
			addMessageTextContent( "|" );
			if( message.infoUserID != firstMsgInfoUserId ) {
				removeMessageClickHandler();
			}
		}
		//Make sure the message we are appending is not null
		if( ( sentDate == null ) ||
		    ( ( message.sentDate.getTime() - sentDate.getTime() ) > APPENDED_MESSAGE_DATE_NOTIFICATION_INTERVAL_MILLISEC ) ) {
			//Make a note about the additional message time if it is more than a certain period of time older
			final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( PredefinedFormat.DATE_TIME_MEDIUM );
			final Label timeStampLabel = new Label( "[" + dateTimeFormat.format( message.sentDate ) + "]" );
			timeStampLabel.addStyleName( CommonResourcesContainer.CHAT_MESSAGE_TITLE_STYLE );
			addMessageContentWidget( timeStampLabel );
			//Update the message sending date
			sentDate = message.sentDate;
		}
		//Append the message content without the recipients
		addMessageContent( message, visibleUsers, roomID, false );
	}
}
 
開發者ID:ivan-zapreev,項目名稱:x-cure-chat,代碼行數:38,代碼來源:ChatMessageBaseUI.java


注:本文中的com.google.gwt.i18n.client.DateTimeFormat.format方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。