Example #1
0
 public static void printDate(String date) {
   Calendar cal = DateHelper.parseDate(date);
   DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG);
   System.out.println(cal.getTimeZone());
   System.out.println(df.format(cal.getTime()));
   df.setTimeZone(cal.getTimeZone());
   System.out.println(df.format(cal.getTime()));
   System.out.println(DateHelper.toDateString(cal));
 }
Example #2
0
 public List format(IFormatter formatter, IMediaProvider mediaProvider) {
   List ret = new LinkedList();
   if (getValueType() != VARIABLE_VALUE) {
     Calendar date = DateHelper.parseDate(getValue());
     if (date != null)
       ret.addAll(
           formatter.formatDate(
               date,
               mediaProvider.getFormatManager().getFormat(this, getFormatName()),
               getFormatOptions(),
               mediaProvider.getResourceManager()));
     else {
       TextContent textContent = new TextContent();
       if (this.getValueType() == FormattableContent.STATIC_VALUE)
         textContent.setStaticText(this.getValue());
       else textContent.setVariableText(this.getValue());
       ret.add(textContent);
     }
   }
   return ret;
 }
Example #3
0
 public static void main(String[] args) {
   String[] dates =
       new String[] {
         "3/4/1977 3:45:34 pm EST",
         "3/4/1977 3:45:34 pm",
         "3/4/1977 3:45:34 EST",
         "3/4/1977 3:45 pm EST",
         "3/4/1977 3:45 pm",
         "3/4/1977 3:45 EST",
         "3:45:34 pm EST",
         "3:45:34 pm",
         "3:45:34 EST",
         "3/31/2010 3:45:34 pm EST",
         "1-4-1977",
         "6/4/1977"
       };
   for (String date : dates) {
     printDate(date);
   }
   Calendar cal = Calendar.getInstance();
   System.out.println(DateHelper.toDateString(cal));
   System.out.println(DateFormat.getDateTimeInstance().format(cal.getTime()));
 }