Esempio n. 1
0
 /**
  * Returns a date in the local time zone parsed from an X.208 formatted date. Only
  * yyyyMMddHHmmss.S (local time) and yyyyMMddHHmmss.SZ (GMT time) formats are recognized.
  *
  * @param expirationDate an X.208 GeneralizedTime, local or GMT.
  * @return the corresponding Date in the local time zone.
  */
 public static Date getLocalDate(String expirationDate) throws java.text.ParseException {
   final SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss.S");
   Date localDate = fmt.parse(expirationDate);
   if (expirationDate.endsWith("Z")) {
     final Date date = new Date();
     if (fmt.getCalendar().getTimeZone().inDaylightTime(date))
       localDate =
           new Date(
               localDate.getTime()
                   + fmt.getCalendar().getTimeZone().getRawOffset()
                   + fmt.getCalendar().getTimeZone().getDSTSavings());
     else
       localDate = new Date(localDate.getTime() + fmt.getCalendar().getTimeZone().getRawOffset());
   }
   return localDate;
 }
 private Object getValueFromField(int propertyType) throws ParseException {
   switch (nodePropertyParameters.propertyType) {
     case PropertyType.BINARY:
       return null;
     case PropertyType.BOOLEAN:
       return booleanValue.isSelected();
     case PropertyType.DATE:
       SimpleDateFormat dateFormat = new SimpleDateFormat();
       dateFormat.setLenient(true);
       String fieldText = dateValue.getText();
       dateFormat.parse(fieldText);
       return dateFormat.getCalendar();
     case PropertyType.DOUBLE:
       return Double.parseDouble(doubleValue.getText());
     case PropertyType.LONG:
       return Long.parseLong(longValue.getText());
     case PropertyType.NAME:
       return nameValue.getText();
     case PropertyType.PATH:
       return pathValue.getText();
     case PropertyType.REFERENCE:
       return referenceValue.getText();
     case PropertyType.STRING:
       return stringValue.getText();
     default:
       return null;
   }
 }
Esempio n. 3
0
 private void testDateFormatting() {
   try {
     String siteDateFormat = "dd.MM.yy HH:mm:ss z";
     String testTime = "10.11.08 13:54:28 MET";
     SimpleDateFormat sdf = new SimpleDateFormat(siteDateFormat, Locale.US);
     Date endingDate = sdf.parse(testTime);
     TimeZone tz = sdf.getCalendar().getTimeZone();
     JConfig.log().logMessage("EndingDate: " + endingDate + "\nTZ: " + tz);
   } catch (ParseException e) {
     e.printStackTrace();
   }
 }
  public static void main(String[] args) throws ParseException {

    String[] string = {"Sunday", "Monday", "Wednesday", "Tuesday", "Thurday", "Friday", "Saturday"};
    Date date = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    // System.out.println(dateFormat.format(date));
    Date date1 = dateFormat.parse("2/2/2016");
    // System.out.println(date1);
    // System.out.println(date.after(date1));
    Calendar calendar = dateFormat.getCalendar();
    calendar.set(1996, 1, 3);
    // System.out.println(calendar.DAY_OF_WEEK);
    System.out.println(string[calendar.get(calendar.DAY_OF_WEEK) - 1]);
  }
Esempio n. 5
0
    @Override
    public void print(RevCommit commit) throws IOException {
      Ansi ansi = AnsiDecorator.newAnsi(useColor);

      ansi.a("Commit:  ").fg(Color.YELLOW).a(getIdAsString(commit.getId())).reset().newline();
      if (commit.getParentIds().size() > 1) {
        ansi.a("Merge: ");
        for (ObjectId parent : commit.getParentIds()) {
          ansi.a(parent.toString().substring(0, 7)).a(" ");
        }
        ansi.newline();
      }
      ansi.a("Author:  ").fg(Color.GREEN).a(formatPerson(commit.getAuthor())).reset().newline();

      final long timestamp = commit.getAuthor().getTimestamp();
      final int timeZoneOffset = commit.getAuthor().getTimeZoneOffset();

      String friendlyString = estimateSince(now, timestamp);
      DATE_FORMAT.getCalendar().getTimeZone().setRawOffset(timeZoneOffset);
      String formattedDate = DATE_FORMAT.format(timestamp);

      ansi.a("Date:    (")
          .fg(Color.RED)
          .a(friendlyString)
          .reset()
          .a(") ")
          .a(formattedDate)
          .newline();
      ansi.a("Subject: ").a(commit.getMessage()).newline();
      if ((detail.equals(LOG_DETAIL.NAMES_ONLY)) && commit.getParentIds().size() == 1) {
        ansi.a("Affected paths:").newline();
        Iterator<DiffEntry> diff =
            geogit
                .command(DiffOp.class)
                .setOldVersion(commit.parentN(0).get())
                .setNewVersion(commit.getId())
                .call();
        DiffEntry diffEntry;
        while (diff.hasNext()) {
          diffEntry = diff.next();
          ansi.a("\t" + diffEntry.newPath()).newline();
        }
      }
      if (detail.equals(LOG_DETAIL.STATS) && commit.getParentIds().size() == 1) {

        Iterator<DiffEntry> diff =
            geogit
                .command(DiffOp.class)
                .setOldVersion(commit.parentN(0).get())
                .setNewVersion(commit.getId())
                .call();
        int adds = 0, deletes = 0, changes = 0;
        DiffEntry diffEntry;
        while (diff.hasNext()) {
          diffEntry = diff.next();
          switch (diffEntry.changeType()) {
            case ADDED:
              ++adds;
              break;
            case REMOVED:
              ++deletes;
              break;
            case MODIFIED:
              ++changes;
              break;
          }
        }

        ansi.a("Changes:");
        ansi.fg(Color.GREEN)
            .a(adds)
            .reset()
            .a(" features added, ")
            .fg(Color.YELLOW)
            .a(changes)
            .reset()
            .a(" changed, ")
            .fg(Color.RED)
            .a(deletes)
            .reset()
            .a(" deleted.")
            .reset()
            .newline();
      }

      console.println(ansi.toString());
      if (detail.equals(LOG_DETAIL.SUMMARY) && commit.getParentIds().size() == 1) {
        ansi.a("Changes:").newline();
        Iterator<DiffEntry> diff =
            geogit
                .command(DiffOp.class)
                .setOldVersion(commit.parentN(0).get())
                .setNewVersion(commit.getId())
                .call();
        DiffEntry diffEntry;
        while (diff.hasNext()) {
          diffEntry = diff.next();
          if (detail.equals(LOG_DETAIL.SUMMARY)) {
            new FullDiffPrinter(true, false).print(geogit, console, diffEntry);
          }
        }
      }
    }