Servlet Date Operations

Slides:



Advertisements
Similar presentations
Georgia Building Authority Parking & Access Services Online Building Access System Agency Access Reports August 26, 2010.
Advertisements

Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats March 2006.
CS 116 Tutorial 6 Strings, Raw Input, Lists. 1. Write a function convert_format that consumes nothing, but takes keyboard input. The program prompts "Enter.
Session 3BBK P1 Module05-May-2007 : [‹#›] Date Manipulation.
Server-Side Scripting with JSP (2) ISYS 350. Post Back A postback is call to the same page that the form is on. In other words, the contents of the form.
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Internationalization of Java Platform Presenter: Ataru Nakazawa Advisor: Xiaoping Jia Date: January 23, 2004.
Time & Date Representation in Java. Date class An object of type Date represents an instance in time Part of java.util.* (requires import statement) A.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.
M1M2M3M4M5M6 M10 M20 M30 M40 M50 M M1M2M3M4M5M6.
Navigation and Ancillary Information Facility NIF Time Conversion and Formats June 2004.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats January 2009.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats November 2014.
CIS 270—Application Development II Chapter 28—Formatted Output.
Server-Side Scripting with JSP (2) ISYS 350. Java Array Examples of declaring an array: – int[] anArray = new int[10]; 10 elements index from 0 to 9 –
Mark Dixon Page 1 3 – Web applications: Server-side code (JSP)
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Dynamic Pages – Quiz #11 Feedback (under assignments) Lecture Code:
JAC444: Dates Tim McKenna Dates, Calendars, and what year is this? §Java tries to take an OOD approach to “when is now?” §import java.util.*;
3 Kinds of Libraries And some reflections on libraries in general As you arrive…please sit with your Tivoo groups.
Server-Side Scripting with JSP (2) ISYS 350. Java Array Examples of declaring an array: – int[] anArray = new int[10]; 10 elements index from 0 to 9 –
CS 174: Web Programming September 28 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Using Dates in Excel Stored as a “serial number” which represents the number of days that have taken place since the beginning of the year 1900 – 1/1/1900=1.
Garside, JAVA: First Contact, 2ed Java First Contact – 2 nd Edition Garside and Mariani Chapter 6 More Java Data Types.
Clear Project Management Steering Group Meeting Pack Project: Pack Number: Project Manager: Department: Date: dd mmmm yyyy Version 1.0.
BACKUP 1. Backup module 2. Manual backup. Double click the Backup TanayTech. 1. Backup module.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats March 2010.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats January 2008.
Texas State Technical College DISCOVER! Conversion Functions “Convert this!”
IMS 3253: Dates and Times 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Date and Time Data Turning Strings into.
The reading is 7.38 mm. The reading is 7.72 mm.
Working with Date ISYS 350.
Java Programming Static Methods.
Handling Errors in Web Applications
Open Source Server Side Scripting Permissions & Users
Java String and Date ISYS 350.
SQL – Dates and Times.
SQL DATE/TIME FUNCTIONS
COMPUTER 2430 Object Oriented Programming and Data Structures I
Java Date ISYS 350.
Simple Java I/O part I Using scanner 8-Nov-18.
Lessons Learned by Team ‘x’ ‘Name of team members’ Date (dd-mm-yyyy)
PLM-Europe Presentation Template :9 Format Usage: Please copy
Time is not on my side.
SQL OVERVIEW DEFINING A SCHEMA
Prepared by, S.Amudha AP/SWE
Lecture Set 6 The String and DateTime Data Types
sscanf()- string scan function
[Document title] [Author Name and affiliation].
Date-time.
Name of speaker, Role in Project
Java Date ISYS 350.
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Introduction to Programming with Python
HTML5 Form Types – Newer Available Fields
ხელმძღვანელი: დიმიტრი ქარაული
MySQL Database System Installation Overview SQL summary
Kirkwood Center for Continuing Education
Lecture 5 SQL FUNCTIONS.
Java Date ISYS 350.
VistA Internationalization Project Group—CPRS Dates
Strings and Dates in JavaScript
Trainer: Bach Ngoc Toan– TEDU Website:
Trainer: Bach Ngoc Toan– TEDU Website:
Database Instructor: Bei Kang.
Advanced hands-on on programmatic access to an Open Access Repository
Java Date ISYS 350.
Ballot Comment Resolution
Working with dates and times
Presentation transcript:

Servlet Date Operations

Getting date from the user Through HTML Form Since we are using bootstrap, date input must use bootstrap standard gui One of the plugins out there bootstrap-datetimepicker.min.js Jquery bootstrap date picker Can format the input MY format – mm-dd-yyyy

MYSQL DATE DATE DATETIME Conversion is needed Yyyy-mm-dd DATETIME Yyyy-mm-dd hh:mm:ss – NOW | current time and date Conversion is needed From dd-mm-yyyy to yyyy-mm-dd

Java string to date conversion String input from html form must be parsed into a java date object. //convert string to date String traveldate = request.getParameter("traveldate"); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); Date date = new Date(); try { date = formatter.parse(traveldate); } catch (Exception ex) { }

MY to mysql format conversion //convert to mysql date formatter = new SimpleDateFormat("yyyy-MM-dd"); traveldate = formatter.format(date);

NOW() function for mysql Exist in php for getting the current time and date Usually use to capture transaction date NOW() funtion not exist in Java Need to do manually

Current time and date in Java //get current date and time Date currentdate = new Date(); //format directly to mysql date SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String bookingdate = formatter.format(currentdate);

MYSQL TO JAVA DATE CONVERSION MYSQL DATE TO JAVA DATE //yyyy-MM-dd String traveldate = rs.getString("traveldate"); //convert traveldate string to date (still mysql date) SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); try { date = formatter.parse(traveldate); } catch (Exception ex) {}

//convert mysql date to MY date formatter = new SimpleDateFormat("dd-MM-yyyy"); traveldate = formatter.format(date);

MYSQL TO JAVA DATE CONVERSION MYSQL DATETIME TO JAVA DATETIME //yyyy-MM-dd HH:mm:ss //parse the date from string for date conversion String bookingdate = rs.getString("bookingdate"); formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); date = new Date(); try { date = formatter.parse(bookingdate); } catch (Exception ex) {}

//convert to MY format dd-MM-yyyy formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss a"); //formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss a"); //formatter = new SimpleDateFormat("dd MMMM, yyyy HH:mm:ss a"); bookingdate = formatter.format(date); a – AM/PM LET SAY MONTH IS NOVEMBER MM – 11 MMM – NOV MMMM – NOVEMBER