Thursday 12 April 2018

ASN.1: DATE: Working with dates

Type: DATE

Description: Used to represent date. It should be of the form "YYYY-MM-DD".   

Example
dateOfBirth DATE

Example Schema
Occupation ::=  BIT STRING {
    clerk        (0),
    watchman     (1),
    engineer     (2),
    manager      (3)
}
    
Hobbies ::= BIT STRING {
    chess     (0),
    cricket   (1),
    hockey    (2),
    football  (3),
    others    (4)
}
    
Employee ::= SEQUENCE {
 name VisibleString,
 isPermanentEmployee BOOLEAN,
 id VisibleString,
 age INTEGER (15..60),
 occupation Occupation,
 hobbies Hobbies,
 dateOfBirth DATE
}

Sample data for above schema
employee1 Employee ::= {
 name "Rama Krishna",
 isPermanentEmployee FALSE,
 id "123456",
 age 30,
 occupation '010'B,
 hobbies {chess, football},
 dateOfBirth "1988-05-05"
}

XML encoding of above data

<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <isPermanentEmployee><false/></isPermanentEmployee>
  <id>123456</id>
  <age>30</age>
  <occupation>01</occupation>
  <hobbies>1001</hobbies>
  <dateOfBirth>1988-05-05</dateOfBirth>
</Employee>



Previous                                                 Next                                                 Home

No comments:

Post a Comment