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


Java DateTimeFormat類代碼示例

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


DateTimeFormat類屬於com.google.gwt.i18n.client包,在下文中一共展示了DateTimeFormat類的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: Cell

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
Cell(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setHTML("");
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:26,代碼來源:PeriodPreferencesWidget.java

示例3: D

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
private D(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	setText(DateTimeFormat.getFormat("d").format(date));
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:26,代碼來源:PeriodPreferencesWidget.java

示例4: getDateFlag

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
@Override
public SessionMonth.Flag getDateFlag(EventType type, Date date) {
	if (iSessionMonths == null || iSessionMonths.isEmpty()) return null;
	if (date == null) return null;
	int m = Integer.parseInt(DateTimeFormat.getFormat("MM").format(date));
	for (SessionMonth month: iSessionMonths)
		if (m == month.getMonth() + 1) {
			int d = Integer.parseInt(DateTimeFormat.getFormat("dd").format(date)) - 1;
			if (month.hasFlag(d, SessionMonth.Flag.FINALS) && type != EventType.FinalExam) return SessionMonth.Flag.FINALS;
			if (month.hasFlag(d, SessionMonth.Flag.BREAK)) return SessionMonth.Flag.BREAK;
			if (month.hasFlag(d, SessionMonth.Flag.WEEKEND)) return SessionMonth.Flag.WEEKEND;
			if (month.hasFlag(d, SessionMonth.Flag.HOLIDAY)) return SessionMonth.Flag.HOLIDAY;
			if (month.hasFlag(d, SessionMonth.Flag.MIDTERMS) && type != EventType.MidtermExam) return SessionMonth.Flag.MIDTERMS;
			return null;
		}
	return null;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:18,代碼來源:EventRoomAvailability.java

示例5: refreshMessageReceivedRow

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
/**
 * Refresh message received row
 *
 * @param messageReceived
 */
private void refreshMessageReceivedRow(final GWTMessageReceived messageReceived, int row) {
	boolean seen = (messageReceived.getSeenDate() == null);

	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), messageReceived);
	dataTable.setHTML(row, 0, "");
	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(messageReceived.getFrom(), seen));
	dataTable.setHTML(
			row,
			2,
			UtilComunicator.getTextAsBoldHTML(
					GeneralComunicator.i18nExtension("messaging.message.type.message.sent"), seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(messageReceived.getSentDate()), seen));
	dataTable.setHTML(row, 4, UtilComunicator.getTextAsBoldHTML(messageReceived.getSubject(), seen));
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:22,代碼來源:ExtendedScrollTable.java

示例6: writeComment

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
/**
 * Writes the note
 */
private void writeComment(GWTWorkflowComment comment) {
	int row = tableNotes.getRowCount();
	tableNotes.setHTML(row, 0, "<b>" + comment.getActorId() + "</b>");
	DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
	tableNotes.setHTML(row, 1, dtf.format(comment.getTime()));
	tableNotes.getCellFormatter().setHorizontalAlignment(row, 1, HasAlignment.ALIGN_RIGHT);
	tableNotes.getRowFormatter().setStyleName(row, "okm-Notes-Title");
	tableNotes.getCellFormatter().setHeight(row, 1, "30px");
	tableNotes.getCellFormatter().setVerticalAlignment(row, 0, HasAlignment.ALIGN_BOTTOM);
	tableNotes.getCellFormatter().setVerticalAlignment(row, 1, HasAlignment.ALIGN_BOTTOM);
	row++;
	tableNotes.setHTML(row, 0, "");
	tableNotes.getCellFormatter().setHeight(row, 0, "6px");
	tableNotes.getRowFormatter().setStyleName(row, "okm-Notes-Line");
	tableNotes.getFlexCellFormatter().setColSpan(row, 0, 2);
	row++;
	tableNotes.setHTML(row, 0, comment.getMessage());
	tableNotes.getFlexCellFormatter().setColSpan(row, 0, 2);
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:23,代碼來源:WorkflowFormPanel.java

示例7: 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

示例8: getStartDate

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
private void getStartDate(){

        String url = Consts.HOST_URL + "/summary/startTime";

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

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

            @Override
            public void onSuccess(TweetTimes result) {
                // Fire SetDateEvent to change date picker to default date from server
                DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
                Date startDate = dateTimeFormat.parse(result.getStartDate());
                Date endDate = dateTimeFormat.parse(result.getEndDate());

                presenter.getEventBus().fireEvent(new SetDateEvent(startDate, endDate));

            }
        });
    }
 
開發者ID:WSDOT,項目名稱:social-analytics,代碼行數:27,代碼來源:AnalyticsViewImpl.java

示例9: formatPastDate

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
/**
 * Package-private version, takes a fixed "now" time - used for testing
 */
String formatPastDate(Date date, Date now) {

  // NOTE(zdwang): For now skip it for junit code; also see formatDateTime()
  if (!GWT.isClient()) {
    return "formatPastDate is not yet implemented in unit test code";
  }

  if (!isValid(date, now)) {
    GWT.log("formatPastDate can only format time in the past, trying anyway", null);
  }

  if (isRecent(date, now, 12 * HOUR_MS) || onSameDay(date, now)) {
    return formatTime(date);
  } else if (isRecent(date, now, 30 * DAY_MS)) {
    return getMonthDayFormat().format(date) + " " + formatTime(date);
  } else if (isSameYear(date, now)) {
    return getMonthDayFormat().format(date);
  } else {
    return DateTimeFormat.getMediumDateFormat().format(date);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:25,代碼來源:DateUtils.java

示例10: shortFormatPastDate

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
/**
 * Package-private version, takes a fixed "now" time - used for testing
 */
String shortFormatPastDate(Date date, Date now) {

  // NOTE(zdwang): For now skip it for junit code; also see formatDateTime()
  if (!GWT.isClient()) {
    return "formatPastDate is not yet implemented in unit test code";
  }

  if (!isValid(date, now)) {
    GWT.log("formatPastDate can only format time in the past, trying anyway", null);
  }

  if (isRecent(date, now, 12 * HOUR_MS) || onSameDay(date, now)) {
    return formatTime(date);
  } else if (isSameYear(date, now)) {
    return getMonthDayFormat().format(date);
  } else {
    return DateTimeFormat.getShortDateFormat().format(date);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:23,代碼來源:DateUtils.java

示例11: 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

示例12: load

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
public void load(TableModel t) {
	getStore().clear();
	if (t != null) {
		store.add(new ModelPropertyModel("表名", t.getName()));
		store.add(new ModelPropertyModel("所有者", t.getOwner()));
		store.add(new ModelPropertyModel("創建時間", DateTimeFormat
				.getFormat("yyyy-MM-d HH:mm:ss").format(t.getCreateDate())
				.toString()));
		store.add(new ModelPropertyModel("路徑", t.getPath()));
		String inputFormat = t.getInputFormat();
		if (inputFormat.equals("org.apache.hadoop.mapred.TextInputFormat")) {
			inputFormat = "TextFile";
		} else if (inputFormat
				.equals("org.apache.hadoop.mapred.SequenceFileInputFormat")) {
			inputFormat = "SequenceFile";
		} else if (inputFormat
				.equals("org.apache.hadoop.hive.ql.io.RCFileInputFormat")) {
			inputFormat = "RCFile";
		}
		store.add(new ModelPropertyModel("存儲格式", inputFormat));
		store.add(new ModelPropertyModel("注釋", t.getComment()));
		char fieldDelim = t.getFieldDelim()==null? '\001':t.getFieldDelim().toCharArray()[0];
		store.add(new ModelPropertyModel("列分割符", fieldDelim+"("+getUnicode(fieldDelim)+")"));
		store.add(new ModelPropertyModel("公共表數據字典","請在代碼中配置"));
	}
}
 
開發者ID:ctripcorp,項目名稱:dataworks-zeus,代碼行數:27,代碼來源:TableInfoTab.java

示例13: processResult

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
@Override
public void processResult(String result) {
    JSONArray array = controller.parseJSON(result).isArray();
    if (array != null) {
        String timeStamp = DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE)
                                         .format(new Date(System.currentTimeMillis()));
        addRow();

        loadTable.setValue(loadTable.getNumberOfRows() - 1, 0, timeStamp);

        // getting primitive values of all attributes
        for (int i = 0; i < attrs.length; i++) {
            double value = array.get(i).isObject().get("value").isNumber().doubleValue();
            loadTable.setValue(loadTable.getNumberOfRows() - 1, i + 1, formatValue(value));
        }

        loadChart.draw(loadTable, loadOpts);
    }
}
 
開發者ID:ow2-proactive,項目名稱:scheduling-portal,代碼行數:20,代碼來源:MemoryLineChart.java

示例14: relativeTime

import com.google.gwt.i18n.client.DateTimeFormat; //導入依賴的package包/類
/**
 * 
 * @param createdAt
 * @param datePattern
 * @param isUTC
 * @return
 */
public static String relativeTime(String createdAt, String datePattern, boolean isUTC) {
	DateTimeFormat parseDateFormat = DateTimeFormat.getFormat(datePattern);
	Date parseDate;

	try {
		if (isUTC) {
			parseDate = parseDateFormat.parse(parseDateFormat.format(
					parseDateFormat.parse(createdAt),
					TimeZone.createTimeZone(0)));
		} else {		
			parseDate = parseDateFormat.parse(createdAt);
		}
	} catch (IllegalArgumentException e) {
		return "Unavailable";
	}

	return getRelative(parseDate);

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

示例15: 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


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