Nic Shulver, Date and Time in JSP Surely it must be easy? Many calendars exist. The year 2013 (“Gregorian” or “Western”) is also:

Slides:



Advertisements
Similar presentations
Mav Mark 10/3/11 How do you convert a motor into a generator?
Advertisements

Calendars Calendars from different cultures. Keeping Time Today you probably think of a year as 365 days, but why do we have 365 days? The 365 day year.
Announcements Homework Set 1 is due today
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 1 Abstract Classes and Interfaces.
CALENDARSCALENDARS Chapter 3 The YEAR 2000 WAS YearAccording to: 1997Christ’s actual birth circa 4 BC 2753Old Roman calendar 2749Ancient Babylonian calendar.
Where and When Objectives Understand what the Modified Julian Calendar is and why it was made. Be able to tell today’s date in the Modified Julian Calendar.
The Whirligig of Time Astronomy 360. Essay 2 Keeping Time The length of the day is set by the earth’s rotation on its axis With some reservations! The.
AST 208 Topics Time and celestial coordinates. Telescopes.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: IO *Standard Output *Formatting Decimal.
Cupertino, CA, USA / September, 2000First ICU DeveloperWorkshop1 Date/Time/Number Formatting Alan Liu Globalization Center of Competency IBM Emerging Technology.
From Julian to Gregorian.  Used during the Middle Ages  The rest of Europe used the Julian calendar  The new day would begin at sunset  If someone.
Which of the following is correct:
CONFIDENTIAL1 Good Afternoon! Today we will be learning about Temperature, changes, & negative numbers Let’s warm up : Complete the conversion tables:
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 –
Time What Time Is It? Before 1884, almost every town in the world kept its own local time. There were no national or international conventions which set.
What is History? Webster: A chronological record of significant events (as affecting a nation or institution) usually of their causes Webster: A chronological.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 26 Internationalization.
Chapter 12: Internationalization Processing Date and Time Processing Date and Time  Locale  Date  TimeZone  Calendar and GregorianCalendar  DateFormat.
1 1 Abstract Classes and Interfaces. 22 Motivations You learned how to write simple programs to display GUI components. Can you write the code to respond.
By Nga Lai Wong Chelsea Lin Chan Chi Wai Aletheia Mohn.
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.*;
Earth’s Orbit and the Seasons. Seasons on the Earth.
Intro To Astronomy.
CALENDARSCALENDARS Chapter 3. The YEAR 2000 WAS YearAccording to: 1997Christ’s actual birth circa 4 BC 2753Old Roman calendar 2749Ancient Babylonian calendar.
Place your chosen image here. The four corners must just cover the arrow tips. For covers, the three pictures should be the same size and in a straight.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Dates and Times. Slide 2 Introduction to Dates and Times (1) The DateTime data type is used to store dates and times There is a date part There is a time.
The Solar System and Beyond The Moon. Gravity also keeps the moon in orbit around the Earth. The moon orbits the Earth every… …month (28 days)
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 –
Garside, JAVA: First Contact, 2ed Java First Contact – 2 nd Edition Garside and Mariani Chapter 6 More Java Data Types.
The Mathematics of Time A/P Helmer Aslaksen Dept. of Mathematics National University of Singapore
Happy Haunted Homeroom October 9, 2012 Today is Tuesday, you have academic and I.S. with your Period 2 teacher.
1 Chapter 20 Internationalization. 2 Objectives F To describe Java's internationalization features (§ 20.1). F To construct a locale with language, country,
Table of Contents  Title: Natural Time Periods (Lunar Month)  Page #: 18  Date: 9/24/2012  Title: Natural Time Periods (Lunar Month)  Page #: 18 
BPJ444: Dates Peter Liu Tim McKenna Dates, Calendars, and what year is this? §Java tries to take an OOD approach to “when is now?” §import.
CS 151: Object-Oriented Design September 10 Class Meeting
Announcements Homework Set 1 is due today Homework set 2: Chapter 2 # 46, 50, 52, 53 & 54 + Determine the number of kilometers in 1° of longitude at the.
Java Util Package Prepared by, S.Amudha AP/SWE. Calendar 1.The abstract Calendar class provides a set of methods that allows you to convert a time in.
Announcements No lab after lecture tonight because of the 1 st Quarter night last Tuesday Homework: Chapter 2 # 2, 3, 4, 5, 7 & 8 Binoculars are available.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting DateTime.
Working with Date and Time ISYS 475. How PHP processes date and time? Traditional way: – Timestamp Newer and object oriented way: – DateTime class.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 1 Chapter 15 Abstract Classes and Interfaces.
CONFIDENTIAL1 Good Afternoon! Today we will be learning about Calendar and Years Let’s warm up : Complete the conversion tables: Hours478 Minutes 1) Calculate.
CALENDARS The Creation of the Calendar. THE LUNAR CALENDAR The first calendar that was used was the lunar calendar. The first calendar that was used was.
Home. Our Big, Beautiful Earth How old is our planet? How was it formed? When did life start? When did the dinosaurs live? When did the first humans live?
Joda Time and a Brief History of the World
JSP java server pages.
Working with Date ISYS 350.
Chapter 13 Abstract Classes and Interfaces
Chapter 14 Internationalization
Do you know all these facts?
CMPE 135: Object-Oriented Analysis and Design September 12 Class Meeting Department of Computer Engineering San Jose State University Fall 2017 Instructor:
Java String and Date ISYS 350.
Early Observations of the Sky
CS170 ygao JAVA, C7.
Chapter 13 Abstract Classes and Interfaces
Java Date ISYS 350.
Solar time and Sidereal (Star) Time
An Excel Adventure in Dates and Times Duncan Young
Chapter 12 Abstract Classes and Interfaces
Announcements Dark Sky night Saturday night is looking iffy. Check before heading out to see if it is cancelled. Homework: Chapter.
Java Date ISYS 350.
Solar Equatorial Year = Days
Jeopardy Dates Sequence Addition Time Comparing Q $100 Q $100 Q $100
Chapter 13 Abstract Classes and Interfaces Part 01
Java Date ISYS 350.
Do you know all these facts?
Java Date ISYS 350.
UNITS OF TIME QUESTIONS.
Presentation transcript:

Nic Shulver, Date and Time in JSP Surely it must be easy? Many calendars exist. The year 2013 (“Gregorian” or “Western”) is also: 6763, Assyrian 1420, Bengali 5773–5774, Hebrew 12013, Holocene (Geologist’s calendar) 1434–1435, Islamic – , Unix…

Nic Shulver, Date and Time in JSP How do they work? Most calendars are solar (and lunar) – so there are about 365 days in a year. Gregorian: 365 days 5 hours 49 minutes 12 seconds on average! “Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; …centurial years that are exactly divisible by 400 are still leap years.” Introduction to CalendarsIntroduction to Calendars, 13 September 2007, United States Naval Observatory.

Nic Shulver, Date and Time in JSP Date is time, Calendar is date... The Gregorian calendar provides the standard calendar system used by most of the world The java.util.GregorianCalendar() class provides a lot of date-related functionality The java.util.Date class Date represents a specific instant in time, with millisecond precision It used to handle date and time, but the Calendar classes do dates much better

Nic Shulver, Date and Time in JSP Code Example <% java.util.Calendar currDate = new java.util.GregorianCalendar(); // add 1 to month as Calendar's months start at 0, not 1 int month = currDate.get(currDate.MONTH)+1; int day = currDate.get(currDate.DAY_OF_MONTH); int year = currDate.get(currDate.YEAR); %> The current date is: / / See:

Nic Shulver, Date and Time in JSP Time since the Epoch In the Unix world, time started on the 1 st January, This is called “the epoch” It's just a convenient way to measure elapsed time GregorianCalendar class: computeTime() - “Converts calendar field values to the time value (millisecond offset from the Epoch)”

Nic Shulver, Date and Time in JSP Date object with locales Date Tester

Nic Shulver, Date and Time in JSP Date object with locales <% Date today = new Date(); Locale here = request.getLocale(); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT,here); out.print( " Local date: "+ df.format( today ) ); Locale france = new Locale( "fr","FR" ); df=DateFormat.getDateInstance( df.LONG, france ); out.print( " French date: "+ df.format( today ) );

Nic Shulver, Date and Time in JSP Date object with locales Locale germany = new Locale( "de","DE" ); df=DateFormat.getDateInstance( df.LONG, germany ); out.print( " German date: "+ df.format( today ) ); Locale usa = new Locale( "en","US" ); df=DateFormat.getDateInstance( df.LONG, usa ); out.print( " USA date: "+ df.format( today ) ); %>

Nic Shulver, Date and Time in JSP The DateFormat class Today is <% DateFormat df = DateFormat.getDateInstance(DateFormat.FULL); Date today = new Date(); String msg = df.format(today); out.println(msg); %>

Nic Shulver, Date and Time in JSP Links to developer documents Gregorian Calendar docs: i/java/util/GregorianCalendar.html Date class docs: i/java/util/Date.html

Nic Shulver, Date and Time in JSP More useful links SimpleDateFormat class docs: i/java/text/SimpleDateFormat.html A proposal for “Earth Standard Time”: