List of usage examples for java.text Format parseObject
public Object parseObject(String source) throws ParseException
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("dd-MMM-yy"); Date date = (Date) formatter.parseObject("29-Jan-02"); System.out.println(date);//from w w w . j a v a 2 s.co m }
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("HH:mm:ss Z"); Date date = (Date) formatter.parseObject("22:14:02 -0500"); System.out.println(date);/* w w w .j a va 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss"); Date date = (Date) formatter.parseObject("2002.01.29.08.36.33"); System.out.println(date);/*from w w w. j ava 2s .c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z"); Date date = (Date) formatter.parseObject("Tue, 29 Jan 2004 21:14:02 -0500"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("HH:mm:ss Z", Locale.CANADA); Date date = (Date) formatter.parseObject("21:44:07 Heure normale du Pacifique"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("E, dd MMM yyyy", Locale.CANADA); Date date = (Date) formatter.parseObject("mar., 29 janv. 2002"); }
From source file:org.wiztools.commons.DateUtil.java
/** * Returns java.util.Date object for the ISO 8601 formatted String yyyy-MM-dd. * @param dateStr//from w w w. ja v a 2 s. c om * @return */ public static Date getFromISODateString(final String dateStr){ try{ Format fmt = new SimpleDateFormat("yyyy-MM-dd"); return (Date) fmt.parseObject(dateStr); } catch(ParseException ex) { throw new IllegalArgumentException(ex); } }
From source file:com.anrisoftware.sscontrol.profile.service.ProfilePropertiesImpl.java
@SuppressWarnings("unchecked") private <T> List<T> asTypedList(List<String> property, Format format) throws ParseException { List<T> list = new ArrayList<T>(); for (String value : property) { list.add((T) format.parseObject(value)); }//www .jav a 2 s. c o m return list; }
From source file:com.anrisoftware.propertiesutils.ContextProperties.java
@SuppressWarnings("unchecked") private <T> void addParsedObject(List<T> list, Format format, String value) throws ParseException { list.add((T) format.parseObject(value)); }
From source file:com.anrisoftware.sscontrol.profile.service.ProfilePropertiesImpl.java
/** * Returns a typed profile property. If the profile property was not set * return the default value from the default properties. * * @param key//from ww w . ja v a2 s. c om * the property {@link String} key. * * @param format * the {@link Format} to parse the type. * * @param defaults * default {@link ContextProperties} properties. * * @return the value of the profile property. * * @throws ServiceException * if the profile property was not found. * * @throws ParseException * if the property cannot be parsed to the type. * */ @SuppressWarnings("unchecked") public <T> T profileTypedProperty(String key, Format format, ContextProperties defaults) throws ServiceException, ParseException { Object property = get(key); if (property != null) { String string = property.toString(); return (T) format.parseObject(string.toString()); } property = defaults.getTypedProperty(key, format); if (property != null) { return (T) property; } throw log.noProfileProperty(this, key); }