本文整理汇总了Java中java.nio.file.attribute.BasicFileAttributes.creationTime方法的典型用法代码示例。如果您正苦于以下问题:Java BasicFileAttributes.creationTime方法的具体用法?Java BasicFileAttributes.creationTime怎么用?Java BasicFileAttributes.creationTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.file.attribute.BasicFileAttributes
的用法示例。
在下文中一共展示了BasicFileAttributes.creationTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueAt
import java.nio.file.attribute.BasicFileAttributes; //导入方法依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (columnIndex == 0) {
return templates[rowIndex].getName();
} else if (columnIndex == 1) {
return templates[rowIndex].getVersion();
} else if (columnIndex == 2) {
return templates[rowIndex].getShortDescription();
} else if (columnIndex == 3) {
Path temPath = Paths.get(templates[rowIndex].getFile().getAbsolutePath());
try {
BasicFileAttributes view = Files.getFileAttributeView(temPath, BasicFileAttributeView.class).readAttributes();
FileTime creationTime = view.creationTime();
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
String cTime = df.format(creationTime.toMillis());
return cTime;
} catch (IOException e) {
return "--";
}
} else {
return null;
}
}
示例2: StringKey
import java.nio.file.attribute.BasicFileAttributes; //导入方法依赖的package包/类
StringKey(String title, String tags, BasicFileAttributes fileAttributes, String hashCode, Date importTime, int indexLoc,String filepath,ConcurrentHashMap wordOccurences) {
list[0] = title;
list[1] = tags;
UUID uuid = UUID.randomUUID();
list[2] = (UUID)uuid;
list[3] = fileAttributes;
list[4] = hashCode;
list[5] = fileAttributes.creationTime();
list[6] = importTime;
list[7] = fileAttributes.lastAccessTime();
list[8] = 0;
list[9] = list[8] / (list[7].getTime() - list[6].getTime());
list[11] = 0;
list[12]=filepath;
list[13]=wordOccurences;
list[14]=Integer.toHexString(this.hashCode());
}
示例3: getValueAt
import java.nio.file.attribute.BasicFileAttributes; //导入方法依赖的package包/类
@Override
public Object getValueAt(Object parent, int index) {
if (!(parent instanceof RootNode)) {
if (("template".equals(((TreeTableNode) parent).getType()))) {
switch (index) {
case 0:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getName();
case 1:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getAuthor();
case 2:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getVersion();
case 3:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getDate();
case 4:
return ((TemplateData) ((TreeTableNode) parent).getData()[0]).getShortDescription();
case 5:
Path temPath = Paths.get(TEMPLATE_FOLDER + ((TemplateData) ((TreeTableNode) parent).getData()[0]).getFileName());
try {
BasicFileAttributes view = Files.getFileAttributeView(temPath,BasicFileAttributeView.class).readAttributes();
FileTime creationTime = view.creationTime();
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
String cTime = df.format(creationTime.toMillis());
return cTime;
} catch (Exception e) {
return "--";
}
default:
return null;
}
} else {
if (index < 1)
return ((TreeTableNode) parent).getData()[index];
else
return null;
}
}
return null;
}
示例4: summaryAll
import java.nio.file.attribute.BasicFileAttributes; //导入方法依赖的package包/类
public static void summaryAll() throws IOException{
int sel = jTabbedPane1.getSelectedIndex();
jLabel23.setText(jTabbedPane1.getTitleAt(sel));
jLabel24.setText("File Location : " + titleText.getText());
/**String[] {splitStrings = filesave.getSelectedFile().getName().split("\\.") ;
String extension = splitStrings[splitStrings.length-1] ;
fileext.setText(extension);}**/
jLabel16.setText("File Extention : " + titleExtLa.getText());
JTextArea textPane = (JTextArea) ((JScrollPane) ((JDesktopPane)jTabbedPane1.getComponentAt(sel)).getComponent(0)).getViewport().getComponent(0);
String totaltext= textPane.getText();
String totalwords[]=totaltext.split("\\s");
jLabel21.setText("Total Word Typed : " + totalwords.length);
jLabel5.setText("Total Characters With Spaces : " + totaltext.length());
jLabel22.setText("Total Line : " + BasicEvents.getLineCount(textPane));
if (titleText.getText().contains("Untitled")) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
DateFormat date = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
jLabel27.setText(dateFormat.format(cal.getTime()));
jLabel25.setText(dateFormat.format(cal.getTime()));
} else {
Path filepath = Paths.get(titleText.getText()) ;
BasicFileAttributes attr = Files.readAttributes(filepath, BasicFileAttributes.class);
String dateCreate = ""+attr.creationTime() ; String dateCreat = dateCreate.replace("T", " Time Created : ");
String lastModi = ""+attr.lastModifiedTime() ; String lastMod = lastModi.replace("T", " Last Time Modified : ");
jLabel25.setText("Date Created : " + dateCreat );
jLabel27.setText("Last Date Modified : " + lastMod );
}
}
示例5: getFormattedDate
import java.nio.file.attribute.BasicFileAttributes; //导入方法依赖的package包/类
/**
* Returns formatted date of creation for current file.
* @param path Current file.
* @return Formatted date.
*/
private String getFormattedDate(Path path) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
BasicFileAttributeView faView = Files.getFileAttributeView(path,
BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
BasicFileAttributes attributes = faView.readAttributes();
FileTime fileTime = attributes.creationTime();
return sdf.format(new Date(fileTime.toMillis()));
} catch (IOException e) {
return "";
}
}