public class FieldSaveDate extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Retrieves the date and time on which the document was last saved. By default, the Gregorian calendar is used.
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
| Modifier and Type | Method and Description |
|---|---|
int |
getSwitchType(java.lang.String switchName) |
boolean |
getUseLunarCalendar()
Gets whether to use the Hijri Lunar or Hebrew Lunar calendar.
|
boolean |
getUseSakaEraCalendar()
Gets whether to use the Saka Era calendar.
|
boolean |
getUseUmAlQuraCalendar()
Gets whether to use the Um-al-Qura calendar.
|
void |
setUseLunarCalendar(boolean value)
Sets whether to use the Hijri Lunar or Hebrew Lunar calendar.
|
void |
setUseSakaEraCalendar(boolean value)
Sets whether to use the Saka Era calendar.
|
void |
setUseUmAlQuraCalendar(boolean value)
Sets whether to use the Um-al-Qura calendar.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic boolean getUseLunarCalendar()
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
public void setUseLunarCalendar(boolean value)
throws java.lang.Exception
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
value - Whether to use the Hijri Lunar or Hebrew Lunar calendar.java.lang.Exceptionpublic boolean getUseSakaEraCalendar()
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
public void setUseSakaEraCalendar(boolean value)
throws java.lang.Exception
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
value - Whether to use the Saka Era calendar.java.lang.Exceptionpublic boolean getUseUmAlQuraCalendar()
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
public void setUseUmAlQuraCalendar(boolean value)
throws java.lang.Exception
Examples:
Shows how to use the SAVEDATE field to display the date/time of the document's most recent save operation performed using Microsoft Word.
Document doc = new Document(getMyDir() + "Document.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
builder.writeln(" Date this document was last saved:");
// We can use the SAVEDATE field to display the last save operation's date and time on the document.
// The save operation that these fields refer to is the manual save in an application like Microsoft Word,
// not the document's Save method.
// Below are three different calendar types according to which the SAVEDATE field can display the date/time.
// 1 - Islamic Lunar Calendar:
builder.write("According to the Lunar Calendar - ");
FieldSaveDate field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" SAVEDATE \\h", field.getFieldCode());
// 2 - Umm al-Qura calendar:
builder.write("\nAccording to the Umm al-Qura calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" SAVEDATE \\u", field.getFieldCode());
// 3 - Indian National calendar:
builder.write("\nAccording to the Indian National calendar - ");
field = (FieldSaveDate) builder.insertField(FieldType.FIELD_SAVE_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" SAVEDATE \\s", field.getFieldCode());
// The SAVEDATE fields draw their date/time values from the LastSavedTime built-in property.
// The document's Save method will not update this value, but we can still update it manually.
doc.getBuiltInDocumentProperties().setLastSavedTime(new Date());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.SAVEDATE.docx");
value - Whether to use the Um-al-Qura calendar.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)