com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat Java Examples

The following examples show how to use com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat. 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: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: RepeatableFormItem.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
     * Replace string values of record attributes with types declared by item children.
     * This is necessary as declarative forms do not use DataSource stuff.
     * @param record record to scan for attributes
     * @param item item with possible profile
     * @return resolved record
     */
    private static Record resolveRecordValues(Record record, FormItem item) {
        Field f = getProfile(item);
        if (f != null) {
            for (Field field : f.getFields()) {
                String fType = field.getType();
                if ("date".equals(fType) || "datetime".equals(fType)) {
                    // parses ISO dateTime to Date; otherwise DateItem cannot recognize the value!
                    Object value = record.getAttributeAsObject(field.getName());
                    if (!(value instanceof String)) {
                        continue;
                    }
                    String sd = (String) value;
//                    ClientUtils.severe(LOG, "name: %s, is date, %s", field.getName(), sd);
//                    Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse("1994-11-05T13:15:30Z");
                    try {
                        Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(sd);
                        record.setAttribute(field.getName(), d);
                    } catch (IllegalArgumentException ex) {
                        LOG.log(Level.WARNING, sd, ex);
                    }
                }
            }
        }
        return record;
    }
 
Example #3
Source File: ISO8601.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example #4
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 #5
Source File: FormGenerator.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
public DateEditorValue(PredefinedFormat displayFormat) {
    this.displayFormat = DateTimeFormat.getFormat(displayFormat);
}
 
Example #6
Source File: ToolBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static void print(String title, String user, String session, Widget... widgets) {
	String content = "";
	for (Widget w: widgets)
		content += "<div class=\"unitime-PrintedComponent\">" + w.getElement().getString() + "</div>";
	String html = "<html><header>" +
		"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" +
		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "unitime/gwt/standard/standard.css\">" +
		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "styles/unitime.css\">" +
	    "<link rel=\"shortcut icon\" href=\"" + GWT.getHostPageBaseURL() + "images/timetabling.ico\">" +
	    "<title>UniTime " + CONSTANTS.version() + "| University Timetabling Application</title>" +
		"</header><body class='unitime-Body'>" + 
	    "<span class='unitime-Page'>" +
			"<span class='body'>"+
				"<span class='unitime-PageHeader'>" +
					"<span class='row'>"+
						"<span class='logo'><img src='" + GWT.getHostPageBaseURL() + "images/unitime.png' border='0'/></span>"+
						"<span class='content'>"+
							"<span id='UniTimeGWT:Title' class='title'>" + title + "</span>"+
							"<span class='unitime-Header'>" +
								"<span class='unitime-InfoPanel'>"+
									"<span class='row'>" +
										"<span class='cell middle'>" + user + "</span>" +
										"<span class='cell right'>" + session + "</span>" +
									"</span>" +
								"</span>" +
							"</span>" +
						"</span>" +
					"</span>" +
				"</span>" +
				"<span class='content'>" + content + "</span>" +
			"</span>" +
			"<span class='footer'>" +
				"<span class='unitime-Footer'>" +
					"<span class='row'>" +
						"<span class='cell left'>Printed from UniTime " + CONSTANTS.version() + " | University Timetabling Application</span>" +
						"<span class='cell middle'>" + CONSTANTS.copyright() + "</span>" +
						"<span class='cell right'>" + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(new Date()) + "</span>" +
					"</span>" +
				"</span>" +
			"</span>" +
		"</span></body></html>";
	printf(html);
}
 
Example #7
Source File: ToolBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static void print(List<Page> pages) {
	String html = "<html><header>" +
    		"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" +
    		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "unitime/gwt/standard/standard.css\">" +
    		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "styles/unitime.css\">" +
    	    "<link rel=\"shortcut icon\" href=\"" + GWT.getHostPageBaseURL() + "images/timetabling.ico\">" +
    	    "<title>UniTime " + CONSTANTS.version() + "| University Timetabling Application</title>" +
    		"</header><body class='unitime-Body'>";
	for (Page p: pages) {
		html += "<span class='unitime-PrintedPage'>" +
					"<span class='unitime-Page'>" +
						"<span class='body'>"+
							"<span class='unitime-PageHeader'>" +
								"<span class='row'>"+
									"<span class='logo'><img src='" + GWT.getHostPageBaseURL() + "images/unitime.png' border='0'/></span>"+
									"<span class='content'>"+
										"<span id='UniTimeGWT:Title' class='title'>" + p.getName() + "</span>"+
										"<span class='unitime-Header'>" +
											"<span class='unitime-InfoPanel'>"+
												"<span class='row'>" +
													"<span class='cell middle'>" + p.getUser() + "</span>" +
													"<span class='cell right'>" + p.getSession() + "</span>" +
												"</span>" +
											"</span>" +
										"</span>" +
									"</span>" +
								"</span>" +
							"</span>" +
							"<span class='content'>" + p.getBody().getString() + "</span>" +
						"</span>" +
						"<span class='footer'>" +
							"<span class='unitime-Footer'>" +
								"<span class='row'>" +
									"<span class='cell left'>Printed from UniTime " + CONSTANTS.version() + " | University Timetabling Application</span>" +
									"<span class='cell middle'>" + CONSTANTS.copyright() + "</span>" +
									"<span class='cell right'>" + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(new Date()) + "</span>" +
								"</span>" +
							"</span>" +
						"</span>" +
					"</span>" +
				"</span>";
	}
	html += "</body></html>";
	printf(html);
}
 
Example #8
Source File: UTCTimeBox.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
/**
 * By default the predefined SHORT time format will be used.
 */
public UTCTimeBox() {
    this(DateTimeFormat.getFormat(PredefinedFormat.TIME_SHORT));
}
 
Example #9
Source File: UTCDateBox.java    From gwt-traction with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new UTCDateBox with the medium date format for the
 * current locale.
 */
public UTCDateBox() {
    this(DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM));
}