Demos and Usage of java.text.DateFormat.parse(String source)


   1: 
   2: import java.text.DateFormat;
   3: import java.text.SimpleDateFormat;
   4:         ...
   5:     protected Object convertToDate(Class type, Object value) {
   6:         DateFormat df = new SimpleDateFormat(TS_FORMAT);
   7:         if (value instanceof String) {
   8:         ...
   9: 
  10:                 return df.parse((String) value);
  11:             } catch (Exception pe) {
  12:         ...
  13:     protected Object convertToString(Class type, Object value) {
  14:         DateFormat df = new SimpleDateFormat(TS_FORMAT);

View Full Code Here
   1: 
   2: import java.text.DateFormat;
   3: import java.text.ParseException;
   4:         ...
   5:     public void testFormat() {
   6:         DateFormat formatter = new DifferenceDateFormat();
   7:         Date now = new Date();
   8:         ...
   9:     public void testParse() throws ParseException {
  10:         DateFormat formatter = new DifferenceDateFormat();
  11:         Date now = new Date();
  12:         ...
  13:         Date veryEarly = new Date(0);
  14:         assertEquals(formatter.parse(Long.toString(now.getTime())), now);

View Full Code Here
   1: import java.util.Calendar;
   2: import java.text.DateFormat;
   3: import java.text.ParseException;
   4:         ...
   5:       if (this._state == MODE_CREATE) {
   6:          DateFormat df = new SimpleDateFormat(DATE_STR);
   7: 
   8:         ...
   9:                .getAttributeNS(null, ApacheKeyStoreConstants._ATT_DATE);
  10:          DateFormat df = new SimpleDateFormat(DATE_STR);
  11: 
  12:         ...
  13: 
  14:          return df.parse(dateString.trim());

View Full Code Here
   1: 
   2: import java.text.DateFormat;
   3: import java.text.SimpleDateFormat;
   4:         ...
   5: 
   6:     private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
   7: 
   8:         ...
   9:             try {
  10:                 return DATE_FORMAT.parse(date);
  11:             } catch (Exception ex) {

View Full Code Here
   1: import java.io.IOException;
   2: import java.text.DateFormat;
   3: import java.text.SimpleDateFormat;
   4:         ...
   5: 
   6:     DateFormat dateTimeFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
   7: 
   8:         ...
   9:     DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
  10: 
  11:         ...
  12:                 if (ogrType == ogr.OFTDateTime)
  13:                     return dateTimeFormat.parse(date);

View Full Code Here
   1: import java.io.Serializable;
   2: import java.text.DateFormat;
   3: import java.text.ParseException;
   4:         ...
   5:                 }
   6:                 int[] list={DateFormat.FULL,DateFormat.SHORT,DateFormat.LONG,DateFormat.MEDIUM};
   7:                 for(int iTry=0;iTry<list.length;iTry++){
   8:         ...
   9:                     try {
  10:                         DateFormat df=DateFormat.getDateInstance(list[iTry]);
  11:         ...
  12:                         df.parse(data);

View Full Code Here
   1: 
   2: import java.text.DateFormat;
   3: import java.text.ParseException;
   4:         ...
   5:   private AgentAssetData assetData = null;
   6:   private DateFormat myDateFormat = DateFormat.getInstance();
   7:   private transient Logger log = null;
   8:         ...
   9:     }
  10:     return myDateFormat.parse(dateString).getTime();
  11:   }

View Full Code Here
   1: 
   2: import java.text.DateFormat;
   3: import java.text.DecimalFormat;
   4:         ...
   5:     
   6:     private static DateFormat _FORMATTER = 
   7:         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
   8:         ...
   9:     {
  10:         return _FORMATTER.parse(dateTimeString);
  11:     }

View Full Code Here
   1: 
   2: import java.text.DateFormat;
   3: import java.text.DecimalFormat;
   4:         ...
   5: 
   6:     public static int DEFAULT = DateFormat.DEFAULT;
   7: 
   8:         ...
   9: 
  10:     public static int SHORT = DateFormat.SHORT;
  11: 
  12:         ...
  13:             df.setLenient(false);
  14:             return df.parse(dateText);

View Full Code Here
   1: import java.io.File;
   2: import java.text.DateFormat;
   3: import java.util.Date;
   4:         ...
   5: {
   6:     static DateFormat timestampFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, Locale.UK);
   7: 
   8:         ...
   9: 
  10:         return timestampFormat.parse(dateString);

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.text.DateFormat;
   3: import java.text.SimpleDateFormat;
   4:         ...
   5: 
   6:         DateFormat dateFormat = new SimpleDateFormat( "dd-MMM-yyyy hh:mm:ss zzzz" );
   7:         try {
   8:         ...
   9:             return dateFormat.parse( dateString );
  10:         }
  11:         ...
  12:         try {
  13:             return dateFormat.parse( dateString );

View Full Code Here
   1: import java.io.StreamTokenizer;
   2: import java.text.DateFormat;
   3: import java.text.ParseException;
   4:         ...
   5:   private String clusterId;
   6:   private DateFormat myDateFormat = DateFormat.getInstance(); 
   7:   private boolean haveItemId = false;
   8:         ...
   9:   public long parseDate(String dateString) throws ParseException {
  10:     return myDateFormat.parse(dateString).getTime();
  11:   }

View Full Code Here
   1: import java.sql.Timestamp;
   2: import java.text.DateFormat;
   3: import java.util.ArrayList;
   4:         ...
   5:    public static Date dateTime(String dateString) {
   6:       DateFormat df = new MailDateFormat();
   7:       try {
   8:         ...
   9:          return df.parse(dateString);
  10:       } catch (java.text.ParseException e) {
  11:         ...
  12:    public static String dateTime(Date date) {
  13:       DateFormat df = new MailDateFormat();

View Full Code Here
   1: import java.lang.reflect.Method;
   2: import java.text.DateFormat;
   3: import java.text.ParseException;
   4:         ...
   5: 
   6:   protected DateFormat myDateFormat = DateFormat.getInstance(); 
   7: 
   8:         ...
   9:   public long parseDate(String dateString) throws ParseException {
  10:     return myDateFormat.parse(dateString).getTime();
  11:   }
  12:         ...
  13: 
  14:       String[] l = org.cougaar.util.CSVUtility.parse(arg);

View Full Code Here
   1: import java.sql.Statement;
   2: import java.text.DateFormat;
   3: import java.text.SimpleDateFormat;
   4:         ...
   5:     State s;
   6:     DateFormat dfDate;
   7:         ...
   8:     DateFormat dfTime;
   9:     DateFormat dfDateTime;
  10:         ...
  11:         s.boeing747 = new AircraftImpl(s.ctx, "B747", "Boeing 747", 4, 
  12:                 new SimpleDateFormat("yyyyMMdd").parse("19700101"), new Length("59.6m"), new Length("70.7"),

View Full Code Here