Tabnine Logo
AbstractUserDateFormatter
Code IndexAdd Tabnine to your IDE (free)

How to use
AbstractUserDateFormatter
in
ch.cyberduck.core.date

Best Java code snippets using ch.cyberduck.core.date.AbstractUserDateFormatter (Showing top 20 results out of 315)

origin: iterate-ch/cyberduck

public String getMediumFormat(long milliseconds) {
  return this.getMediumFormat(milliseconds, true);
}
origin: iterate-ch/cyberduck

public String getShortFormat(long milliseconds) {
  return this.getShortFormat(milliseconds, true);
}
origin: iterate-ch/cyberduck

  public String getLongFormat(long milliseconds) {
    return this.getLongFormat(milliseconds, true);
  }
}
origin: iterate-ch/cyberduck

  @Override
  public void apply(final Path file, final Local local, final TransferStatus status,
           final ProgressListener listener) throws BackgroundException {
    if(status.isExists()) {
      Local rename;
      do {
        String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.download.file.rename.format"),
            FilenameUtils.getBaseName(file.getName()),
            UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(local.getDelimiter(), '-').replace(':', '-'),
            StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY);
        rename = LocalFactory.get(local.getParent().getAbsolute(), proposal);
      }
      while(rename.exists());
      if(log.isInfoEnabled()) {
        log.info(String.format("Rename existing file %s to %s", local, rename));
      }
      local.rename(rename);
      if(log.isDebugEnabled()) {
        log.debug(String.format("Clear exist flag for file %s", local));
      }
      status.setExists(false);
    }
    super.apply(file, local, status, listener);
  }
}
origin: iterate-ch/cyberduck

@Override
public NSView getAccessoryView(final NSAlert alert) {
  final NSView view = super.getAccessoryView(alert);
  String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("browser.duplicate.format"),
      FilenameUtils.getBaseName(selected.getName()),
      UserDateFormatterFactory.get().getShortFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, ':'),
      StringUtils.isNotBlank(selected.getExtension()) ? String.format(".%s", selected.getExtension()) : StringUtils.EMPTY);
  this.updateField(inputField, proposal);
  return view;
}
origin: iterate-ch/cyberduck

@Override
public String getComment(final Host host) {
  Date timestamp = host.getTimestamp();
  if(null != timestamp) {
    // Set comment to timestamp when server was last accessed
    return UserDateFormatterFactory.get().getLongFormat(timestamp.getTime());
  }
  // There might be files from previous versions that have no timestamp yet.
  return null;
}
origin: iterate-ch/cyberduck

  @Override
  public DescriptiveUrlBag toUrl(final Path file) {
    final DescriptiveUrlBag list = new DescriptiveUrlBag();
    if(file.isFile()) {
      try {
        // This link will expire in four hours and afterwards you will get 410 Gone.
        final String link = new DbxUserFilesRequests(session.getClient()).getTemporaryLink(file.getAbsolute()).getLink();
        // Determine expiry time for URL
        final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        expiry.add(Calendar.HOUR, 4);
        list.add(new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.http,
          MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3"))
            + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
            UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis()))
        ));
      }
      catch(DbxException e) {
        log.warn(String.format("Failure retrieving shared link. %s", e.getMessage()));
      }
    }
    return list;
  }
}
origin: iterate-ch/cyberduck

    MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
        + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
        UserDateFormatterFactory.get().getShortFormat(expiry * 1000))
));
origin: iterate-ch/cyberduck

public void setMessage(final String message) {
  final String text;
  if(StringUtils.isBlank(message)) {
    // Do not display any progress text when transfer is stopped
    final Date timestamp = transfer.getTimestamp();
    if(null != timestamp) {
      text = UserDateFormatterFactory.get().getLongFormat(timestamp.getTime(), false);
    }
    else {
      text = StringUtils.EMPTY;
    }
  }
  else {
    text = message;
  }
  messageField.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(
    text, TRUNCATE_MIDDLE_ATTRIBUTES));
}
origin: iterate-ch/cyberduck

  /**
   * Rename existing file on server if there is a conflict.
   */
  @Override
  public void apply(final Path file, final Local local, final TransferStatus status,
           final ProgressListener listener) throws BackgroundException {
    // Rename existing file before putting new file in place
    if(status.isExists()) {
      Path rename;
      do {
        final String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.upload.file.rename.format"),
            FilenameUtils.getBaseName(file.getName()),
            UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, '-').replace(':', '-'),
            StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY);
        rename = new Path(file.getParent(), proposal, file.getType());
      }
      while(find.withCache(cache).find(rename));
      if(log.isInfoEnabled()) {
        log.info(String.format("Rename existing file %s to %s", file, rename));
      }
      move.move(file, rename, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback());
      if(log.isDebugEnabled()) {
        log.debug(String.format("Clear exist flag for file %s", file));
      }
      status.setExists(false);
    }
    super.apply(file, local, status, listener);
  }
}
origin: iterate-ch/cyberduck

  @Override
  public DescriptiveUrl toUploadUrl(final Path file, final CreateUploadShareRequest options, final PasswordCallback callback) throws BackgroundException {
    try {
      final UploadShare share = new SharesApi(session.getClient()).createUploadShare(
        options.targetId(Long.parseLong(nodeid.getFileid(file, new DisabledListProgressListener()))), StringUtils.EMPTY, null);
      final String help;
      if(null == share.getExpireAt()) {
        help = MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"));
      }
      else {
        final long expiry = share.getExpireAt().getMillis();
        help = MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
          UserDateFormatterFactory.get().getShortFormat(expiry * 1000)
        );
      }
      return new DescriptiveUrl(
        URI.create(String.format("%s://%s/#/public/shares-uploads/%s",
          session.getHost().getProtocol().getScheme(),
          session.getHost().getHostname(),
          share.getAccessKey())
        ),
        DescriptiveUrl.Type.signed, help);
    }
    catch(ApiException e) {
      throw new SDSExceptionMappingService().map(e);
    }
  }
}
origin: iterate-ch/cyberduck

protected void add(final String fullname, final String hostname, final int port,
          final String user, final String password, final String path) {
  final Protocol protocol = this.getProtocol(fullname);
  if(null == protocol) {
    log.warn(String.format("Unknown service type for %s", fullname));
    return;
  }
  final Host host = new Host(protocol, hostname, port);
  host.getCredentials().setUsername(user);
  host.getCredentials().setPassword(password);
  if(StringUtils.isNotBlank(path)) {
    host.setDefaultPath(PathNormalizer.normalize(path));
  }
  host.setComment(UserDateFormatterFactory.get().getLongFormat(new Date().getTime()));
  this.add(fullname, host);
}
origin: iterate-ch/cyberduck

MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
  + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
  UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis() + expiresIn.toMillis()))));
MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
  + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
  UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis() + expiresIn.toMillis()))));
MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
  + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
  UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis() + expiresIn.toMillis()))));
origin: iterate-ch/cyberduck

private DescriptiveUrl createSignedUrl(final Path file, int seconds) {
  final CloudBlob blob;
  try {
    if(!session.isConnected()) {
      return DescriptiveUrl.EMPTY;
    }
    blob = session.getClient().getContainerReference(containerService.getContainer(file).getName())
        .getBlobReferenceFromServer(containerService.getKey(file));
  }
  catch(URISyntaxException | StorageException e) {
    return DescriptiveUrl.EMPTY;
  }
  final String token;
  try {
    token = blob.generateSharedAccessSignature(this.getPolicy(seconds), null);
  }
  catch(InvalidKeyException | StorageException e) {
    return DescriptiveUrl.EMPTY;
  }
  return new DescriptiveUrl(URI.create(String.format("%s://%s%s?%s",
      Scheme.https.name(), session.getHost().getHostname(), URIEncoder.encode(file.getAbsolute()), token)),
      DescriptiveUrl.Type.signed,
      MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
          + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
          UserDateFormatterFactory.get().getShortFormat(this.getExpiry(seconds))));
}
origin: iterate-ch/cyberduck

this.updateField(modifiedField, UserDateFormatterFactory.get().getLongFormat(
  file.attributes().getModificationDate()),
  TRUNCATE_MIDDLE_ATTRIBUTES
this.updateField(createdField, UserDateFormatterFactory.get().getLongFormat(
  file.attributes().getCreationDate()),
  TRUNCATE_MIDDLE_ATTRIBUTES
origin: iterate-ch/cyberduck

@Override
public DescriptiveUrl toDownloadUrl(final Path file, final Void none, final PasswordCallback callback) throws BackgroundException {
  if(file.isFile()) {
    final String download = String.format("%s/file/%s/%s", session.getClient().getDownloadUrl(),
      URIEncoder.encode(containerService.getContainer(file).getName()),
      URIEncoder.encode(containerService.getKey(file)));
    try {
      final int seconds = 604800;
      // Determine expiry time for URL
      final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
      expiry.add(Calendar.SECOND, seconds);
      final String token = session.getClient().getDownloadAuthorization(fileid.getFileid(containerService.getContainer(file), new DisabledListProgressListener()),
        StringUtils.EMPTY, seconds);
      return new DescriptiveUrl(URI.create(String.format("%s?Authorization=%s", download, token)), DescriptiveUrl.Type.signed,
        MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
          + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
          UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis()))
      );
    }
    catch(B2ApiException e) {
      throw new B2ExceptionMappingService().map(e);
    }
    catch(IOException e) {
      throw new DefaultIOExceptionMappingService().map(e);
    }
  }
  return DescriptiveUrl.EMPTY;
}
origin: iterate-ch/cyberduck

dateFormatter.getShortFormat(item.attributes().getModificationDate(),
  preferences.getBoolean("browser.date.natural")),
TableCellAttributes.browserFontLeftAlignment()
origin: iterate-ch/cyberduck

if(null != timestamp) {
  title.appendAttributedString(NSAttributedString.attributedStringWithAttributes(
    UserDateFormatterFactory.get().getLongFormat(timestamp.getTime()), BundleController.MENU_HELP_FONT_ATTRIBUTES));
origin: iterate-ch/cyberduck

  MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))
    + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")",
    UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis()))
);
origin: iterate-ch/cyberduck

try {
  listener.message(MessageFormat.format(LocaleFactory.localizedString("Changing timestamp of {0} to {1}", "Status"),
    file.getName(), UserDateFormatterFactory.get().getShortFormat(status.getTimestamp())));
  feature.setTimestamp(file, status.getTimestamp());
ch.cyberduck.core.dateAbstractUserDateFormatter

Most used methods

  • getMediumFormat
  • getShortFormat
  • getLongFormat

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now