public class FieldDate extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Inserts the current date and time. By default, the Gregorian calendar is used.
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
| Modifier and Type | Method and Description |
|---|---|
int |
getSwitchType(java.lang.String switchName) |
boolean |
getUseLastFormat()
Gets whether to use a format last used by the hosting application when inserting a new DATE field.
|
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 |
setUseLastFormat(boolean value)
Sets whether to use a format last used by the hosting application when inserting a new DATE field.
|
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 DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
public void setUseLunarCalendar(boolean value)
throws java.lang.Exception
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
value - Whether to use the Hijri Lunar or Hebrew Lunar calendar.java.lang.Exceptionpublic boolean getUseLastFormat()
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
public void setUseLastFormat(boolean value)
throws java.lang.Exception
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
value - Whether to use a format last used by the hosting application when inserting a new DATE field.java.lang.Exceptionpublic boolean getUseSakaEraCalendar()
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
public void setUseSakaEraCalendar(boolean value)
throws java.lang.Exception
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
value - Whether to use the Saka Era calendar.java.lang.Exceptionpublic boolean getUseUmAlQuraCalendar()
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
public void setUseUmAlQuraCalendar(boolean value)
throws java.lang.Exception
Examples:
Shows how to use DATE fields to display dates according to different kinds of calendars.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// If we want the text in the document always to display the correct date, we can use a DATE field.
// Below are three types of cultural calendars that a DATE field can use to display a date.
// 1 - Islamic Lunar Calendar:
FieldDate field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLunarCalendar(true);
Assert.assertEquals(" DATE \\h", field.getFieldCode());
builder.writeln();
// 2 - Umm al-Qura calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseUmAlQuraCalendar(true);
Assert.assertEquals(" DATE \\u", field.getFieldCode());
builder.writeln();
// 3 - Indian National Calendar:
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseSakaEraCalendar(true);
Assert.assertEquals(" DATE \\s", field.getFieldCode());
builder.writeln();
// Insert a DATE field and set its calendar type to the one last used by the host application.
// In Microsoft Word, the type will be the most recently used in the Insert -> Text -> Date and Time dialog box.
field = (FieldDate) builder.insertField(FieldType.FIELD_DATE, true);
field.setUseLastFormat(true);
Assert.assertEquals(" DATE \\l", field.getFieldCode());
builder.writeln();
doc.updateFields();
doc.save(getArtifactsDir() + "Field.DATE.docx");
value - Whether to use the Um-al-Qura calendar.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)