{"id":224,"date":"2020-02-06T13:20:00","date_gmt":"2020-02-06T13:20:00","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?p=224"},"modified":"2020-08-11T17:33:50","modified_gmt":"2020-08-11T17:33:50","slug":"create-the-user-profile-page-working-with-date-and-time","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/spring-boot\/create-the-user-profile-page-working-with-date-and-time\/","title":{"rendered":"Complete Application with Spring Boot \u2013 Part 5 &#8211; Create the User Profile Page (+ Working with Date and Time)"},"content":{"rendered":"<p>In this part, we are going to be creating the user profile page for our application. I&#8217;m going to provide a step by step on how to do this. We\u00a0would kind of focus a little more on working with dates ad times with Thymeleaf.\u00a0 I recommend you watch the video for clarification. Also feel free to let me know in the comment section if you have any challenges.<\/p>\n<p>Remember that in the previous lesson, explained how to encrypt your password using BCrypt Password Encoder (<a href=\"https:\/\/www.youtube.com\/watch?v=jD3pLKoieaw\" target=\"_blank\" rel=\"noopener\">Video here<\/a>). So before we proceed on this lesson, i recommend you make sure that all the passwords are encrypted. See the <a href=\"https:\/\/www.youtube.com\/playlist?list=PL9l1zUfnZkZkmDvzHCoLlc_nHBc7ZXiRO\" target=\"_blank\" rel=\"noopener\">Video Playlist<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Content<\/strong><\/p>\n<ol>\n<li><a href=\"#t1\">Create the ProfileController<\/a><\/li>\n<li><a href=\"#t2\">Modify the Date and Times<\/a><\/li>\n<li><a href=\"#t3\">Display Country Acronym<\/a><\/li>\n<li><a href=\"#t4\">Display Other Field<\/a><\/li>\n<li><a href=\"#t5\">Work with Profile and Edit Profile Tabs<\/a><\/li>\n<li><a href=\"#t6\">We are not Done Yet!<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Follow the steps below:<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t1\">1. Create the ProfileController<\/strong><\/h5>\n<p>Currently the profile.html page is served by the ApplicationController. We need to change that.<\/p>\n<ol>\n<li>Create a ProfileControlle file in the controllers package<\/li>\n<li>Move the profile() method from the ApplicationController to the ProfileController<\/li>\n<li>Adjust the links in the pages to link to the &#8220;\/profile&#8221; endpoint<\/li>\n<li>Test the application to make sure the changes are working<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t2\">2. Modify the Date and Time in the profile.html<\/strong><\/h5>\n<p><strong>a. Current time in 12 hour format with AM\/PM<\/strong><\/p>\n<p>Find and adjust the time field using the markup below: This markup displays the current time<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;span<\/span> <span style=\"color: #0000cc;\">th:text=<\/span><span style=\"background-color: #fff0f0;\">\"${#dates.format(#dates.createNow(), 'hh:mm a')}\"<\/span><span style=\"color: #007700;\">&gt;&lt;\/span&gt;<\/span>\r\n<\/pre>\n<p>The output would be 12:00 AM<\/p>\n<p>&nbsp;<\/p>\n<p><strong>b. Current time in 24 hour format<\/strong><\/p>\n<p>Use the code below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;span<\/span> <span style=\"color: #0000cc;\">th:text=<\/span><span style=\"background-color: #fff0f0;\">\"${#dates.format(#dates.createNow(), 'HH:mm')}\"<\/span><span style=\"color: #007700;\">&gt;&lt;\/span&gt;<\/span>\r\n<\/pre>\n<p>The output would be <strong>16:00<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>c. Current Date in Various formats<\/strong><\/p>\n<p>Find and adjust the date field using the markup below. This displays the current date:<\/p>\n<p><strong>Markup:<\/strong> <!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;span<\/span> <span style=\"color: #0000cc;\">th:text=<\/span><span style=\"background-color: #fff0f0;\">\"${#dates.format(#dates.createNow(), 'dd MMM yyyy')}\"<\/span><span style=\"color: #007700;\">&gt;&lt;\/span&gt;<\/span>\r\n<\/pre>\n<p><strong>Output<\/strong>: 25.10.13<\/p>\n<p>Now, you can try to adjust the formats specification by changing the case of each of the components. Then you can see what the output would look like.<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t3\">3. Display the Country Acronym<\/strong><\/h5>\n<p>We know that countries and state can be represented by 2-letter or 3-letter acrynyms. For example, United States (USA), Hungary(HUN), Nigeria (NGA) etc.<\/p>\n<p>Now we would work on the Country.html page to be able to edit the this fields in the Country table.<\/p>\n<p>We also add an additional column to the Country table\u00a0 to hold the accronym.<\/p>\n<p>All these are explained in the video. But not the SQL statement below to add an additional column to an SQL table.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">ALTER<\/span> <span style=\"color: #008800; font-weight: bold;\">TABLE<\/span> country <span style=\"color: #008800; font-weight: bold;\">ADD<\/span> <span style=\"color: #008800; font-weight: bold;\">COLUMN<\/span> acronym <span style=\"color: #007020;\">VARCHAR<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">3<\/span>);\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If you made an error and wants to drop the table, use the code below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">ALTER<\/span> <span style=\"color: #008800; font-weight: bold;\">TABLE<\/span> country <span style=\"color: #008800; font-weight: bold;\">DROP<\/span> <span style=\"color: #008800; font-weight: bold;\">COLUMN<\/span> acronym;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t4\">4. Display Other Fields<\/strong><\/h5>\n<p>First you need to display the Fullname of the person above the photo. You already know how to do this.<\/p>\n<p>Next we need to add the JobTitle markup below the user photo. The markup is shown below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #007700;\">&lt;span<\/span> <span style=\"color: #0000cc;\">th:text=<\/span><span style=\"background-color: #fff0f0;\">\"${employee.jobtitleid.description}\"<\/span><span style=\"color: #007700;\">&gt;&lt;\/span&gt;<\/span>\r\n<\/pre>\n<p>Then you also need to add your twitter handle. I don&#8217;t think we have this field in our table. So we add it both in SQL and in the Model. Do same with other field above the twitter handle.<\/p>\n<p>Also change the three text fields to the right of the user details.<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t5\">5. Work on Profile and Edit Profile Tabs<\/strong><\/h5>\n<p>The Profile tab contains the user details while the Edit Profiles table contains editable fields.<\/p>\n<p>We would work on the Daily Activities table after now.<\/p>\n<p>In the\u00a0 case of the Profile tab, simply change the names and the markups for the\u00a0 fields.<\/p>\n<p>As for the Edit Profile tab, you\u00a0 need to add the names to the form text fields. This is so that you can submit the values to the server.<\/p>\n<p>Also add\u00a0 FileUpload input to be able to change the user photo to upload new photo.<\/p>\n<p>Finally, once you are sure that all is ok, then write the th:action of the form.<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t6\">6. We are not done yet!<\/strong><\/h5>\n<p>In the next part, we would learn:<\/p>\n<ul>\n<li>how to upload a photo<\/li>\n<li>understand DynamicUpdate (update only changed fields)<\/li>\n<li>how to display a large image when a thumbnail is clicked<\/li>\n<li>add a related table to hold user bio details (@OneToOne)<\/li>\n<li>and more&#8230;<\/li>\n<\/ul>\n<p><iframe loading=\"lazy\" width=\"100%\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/videoseries?list=PL9l1zUfnZkZkmDvzHCoLlc_nHBc7ZXiRO\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In this part, we are going to be creating the user profile page for our application. I&#8217;m going to provide a step by step on &hellip; <!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":225,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[24],"class_list":["post-224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot-tutorials","tag-date-and-times-in-thymeleaf"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/comments?post=224"}],"version-history":[{"count":2,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/224\/revisions"}],"predecessor-version":[{"id":249,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/224\/revisions\/249"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media\/225"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media?parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/categories?post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/tags?post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}