本文整理匯總了Java中com.google.gwt.i18n.client.DateTimeFormat.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeFormat.parse方法的具體用法?Java DateTimeFormat.parse怎麽用?Java DateTimeFormat.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.i18n.client.DateTimeFormat
的用法示例。
在下文中一共展示了DateTimeFormat.parse方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: getParameterValue
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
private Object getParameterValue(Record record, ValueType valueType, DisplayType displayType) {
Object val = record.getAttributeAsObject(WorkflowParameterDataSource.FIELD_VALUE);
if (valueType == ValueType.DATETIME && val instanceof String) {
DateTimeFormat format = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
val = format.parse((String) val);
} else if (displayType == DisplayType.CHECKBOX && val instanceof String) {
if (Boolean.TRUE.toString().equalsIgnoreCase((String) val)) {
val = true;
} else if (Boolean.FALSE.toString().equalsIgnoreCase((String) val)) {
val = false;
} else {
try {
val = new BigDecimal((String) val).compareTo(BigDecimal.ZERO) > 0;
} catch (NumberFormatException e) {
// ignore
}
}
} else if (displayType == DisplayType.CHECKBOX && val instanceof Number) {
val = ((Number) val).doubleValue() > 0;
}
return val;
}
示例3: testSetFormat
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@Test
public void testSetFormat() {
datePicker = new DatePicker(datePickerMock);
String gwtDateFormat = "dd-MMM-yyyy";
DateTimeFormat gwtDateTimeFormat = DateTimeFormat.getFormat(gwtDateFormat);
datePicker.setLocaleName("en");
datePicker.setFormat(gwtDateFormat);
verify(datePickerMock).setLanguage(DatePickerLanguage.EN);
verify(datePickerMock).setFormat(DatePickerFormatUtilities.convertToBS3DateFormat(gwtDateFormat));
Date now = new Date();
now = gwtDateTimeFormat.parse(gwtDateTimeFormat.format(now));
datePicker.setValue(now);
verify(textBox).setValue(gwtDateTimeFormat.format(now));
when(textBox.getValue()).thenReturn(gwtDateTimeFormat.format(now));
assertEquals(now,
datePicker.getValue());
}
示例4: parseExtended
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
* Parse string date in format "YYYY-MM-DDThh:mm:ss.SSSTZD"
*/
public static Date parseExtended(String value) {
if (value == null) {
return null;
} else {
DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
return dtf.parse(value);
}
}
示例5: parseBasic
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
* Parse string date in format "yyyyMMddHHmmss"
*/
public static Date parseBasic(String value) {
if (value == null) {
return null;
} else {
DateTimeFormat dtf = DateTimeFormat.getFormat(BASIC_PATTER);
return dtf.parse(value);
}
}
示例6: parse
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
public static double parse(String fmt, String dateString) {
date.setTime(0);
if(fmt == null) return Date.parse(dateString);
DateTimeFormat dtf = DateTimeFormat.getFormat(fmt);
dtf.parse(dateString, 0, date);
return date.getTime();
}
示例7: isValid
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@Override
public boolean isValid(final String dateString, String attribute) {
DateTimeFormat dateFormat = getDateFormat();
Date parsedDate = null;
try {
parsedDate = dateFormat.parse(dateString);
} catch (IllegalArgumentException ignored) {}
Date now = new Date();
return parsedDate != null && parsedDate.before(now);
}
示例8: isValid
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@Override
public boolean isValid(final String dateString, String attribute) {
DateTimeFormat dateFormat = getDateFormat();
Date parsedDate = null;
try {
parsedDate = dateFormat.parse(dateString);
} catch (IllegalArgumentException ignored) {}
Date now = new Date();
return parsedDate != null && parsedDate.after(now);
}
示例9: getDataPickerDate
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
protected Date getDataPickerDate() {
DateTimeFormat dtf = DateTimeFormat.getFormat("dd/M/yyyy");
String dateStr = parseDate(datePicker.getTextBox().getElement(),
DatePickerFormatUtilities.convertToBS3DateFormat("dd/M/yyyy"));
if(dateStr == null || dateStr.isEmpty()){
return null;
} else {
return dtf.parse(dateStr);
}
}
示例10: init
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
/**
* UI Initialization
*/
protected void init() {
this.setSize("850px", "400px");
this.setGlassEnabled(true);
this.setModal(true);
desc.setText(desc.getText()+" Job Id - "+bdaJobId);
closeButton.setSize("10px", "10px");
closeButton.setStyleName("closebtn");
VerticalPanel topPanel = new VerticalPanel(); //Outermost vertical panel
topPanel.add(closeButton);
topPanel.setCellHeight(closeButton, "13px");
topPanel.setStyleName("vpanel");
desc.setStyleName("popupTitle");
topPanel.add(desc);
topPanel.setCellHeight(desc, "30px");
HorizontalPanel optPanel = new HorizontalPanel(); //Operation panel(include search, batch delete.etc)
optPanel.addStyleName("run-history-optPanel");
DateTimeFormat pickerFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
startTimeBox.setFormat(new DateBox.DefaultFormat(pickerFormat));
startTimeBox.getDatePicker().addStyleName("run-history-datepicker-popup");
endTimeBox.setFormat(new DateBox.DefaultFormat(pickerFormat));
endTimeBox.getDatePicker().addStyleName("run-history-datepicker-popup");
searchBtn.removeStyleName("gwt-Button");
searchBtn.addStyleName("run-history-search-button");
//The initial time is set to 2016-1-1
endTime = new Date();
DateTimeFormat tmpFormatter = DateTimeFormat.getFormat("yyyy-MM-dd");
startTime = tmpFormatter.parse("2016-01-01");
selectAllChkBox.setVisible(false);
batchDelBtn.removeStyleName("gwt-Button");
batchDelBtn.addStyleName("run-history-batch-del-button");
optPanel.add(startTimeLabel);
optPanel.add(startTimeBox);
optPanel.add(endTimeLabel);
optPanel.add(endTimeBox);
optPanel.add(searchBtn);
if(isExample && !AppController.power.equals("111")) //Example job only can be deleted by administrator privileges
{}
else
optPanel.add(batchDelBtn);
optPanel.add(selectAllChkBox);
runHistoryGrid.addStyleName("run-history-table"); //Data view
runHistoryGrid.addStyleName("table-striped");
runHistoryGrid.addStyleName("table-hover");
runHistoryGrid.resize(rowNum, colNum);
for(int i=0;i<colNum;i++)
{
runHistoryGrid.setText(0, i, columns[i]);
}
initGridData();
topPanel.add(optPanel);
topPanel.add(runHistoryGrid);
VerticalPanel bottomPanel = new VerticalPanel(); //Paging control
bottomPanel.add(pageGrid);
bottomPanel.addStyleName("run-history-bottomPanel");
VerticalPanel panel = new VerticalPanel();
panel.add(topPanel);
panel.add(bottomPanel);
this.add(panel);
this.setStyleName("loading_container");
}
示例11: parseDate
import com.google.gwt.i18n.client.DateTimeFormat; //導入方法依賴的package包/類
@Override
public Date parseDate(String pattern, String d) {
DateTimeFormat df = getDateFormat(pattern);
return df.parse(d);
}