import com.aspose.note.Document;
import com.aspose.note.License;
import static com.aspose.note.NodeType.Page;
import com.aspose.note.Page;
import com.aspose.note.ParagraphStyle;
import com.aspose.note.RichText;
import com.aspose.note.Title;
import java.awt.Color;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class NoteToHtml {
    
      public static void main(String[] htmlArgs) throws IOException{
        
        String path="/Users/Documents/TestData/";
        
        // Set the Note API license
        License lic= new License();
        lic.setLicense(path + "Conholdate.Total.Product.Family.lic");

        //Initialize the OneNote document instance
        Document noteDoc = new Document();

        //Add a default empty page inside the document
        Page page = noteDoc.appendChildLast(new Page());

        //Add the styling for the entire text in the document
        ParagraphStyle textStyle = new ParagraphStyle();

        textStyle.setFontColor(Color.BLACK);
        textStyle.setFontName("Arial");
        textStyle.setFontSize(10);

        Title title =  new Title();
               
        RichText titleText = new RichText();
        titleText.setText("Title text.");
        titleText.setParagraphStyle(textStyle);
        title.setTitleText(titleText);
        
        RichText titleDate = new RichText();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");  
        titleDate.setText(dateFormat.format(new Date(2023,6,9)));
        titleDate.setParagraphStyle(textStyle);        
        title.setTitleText(titleDate);

        RichText titleTime = new RichText();
        titleTime.setText("12:23");
        titleTime.setParagraphStyle(textStyle);        
        title.setTitleText(titleTime);

        page.setTitle(title);
              
        //Convert OneNote to HTML format
        noteDoc.save(path + "CreateOneNoteDoc_out.html");
    }
}