পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Friday, January 27, 2017

Clojure - Date and Time

Since the Clojure framework is derived from Java classes, one can use the date-time classes available in Java in Clojure. The class date represents a specific instant in time, with millisecond precision.
Following are the methods available for the date-time class.

java.util.Date

This is used to create the date object in Clojure.

Syntax

Following is the syntax.
java.util.Date.
Parameters − None.
Return Value − Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Example

An example on how this is used is shown in the following program.
(ns example)
(defn Example []
   (def date (.toString (java.util.Date.)))
   (println date))
(Example)

Output

The above program produces the following output. This will depend on the current date and time on the system, on which the program is being run.
Tue Mar 01 06:11:17 UTC 2016

java.text.SimpleDateFormat

This is used to format the date output.

Syntax

Following is the syntax.
(java.text.SimpleDateFormat. format dt)
Parameters − ‘format’ is the format to be used when formatting the date. ‘dt’ is the date which needs to be formatted.
Return Value − A formatted date output.

Example

An example on how this is used is shown in the following program.
(ns example)
(defn Example []
   (def date (.format (java.text.SimpleDateFormat. "MM/dd/yyyy") (new java.util.Date)))
   (println date))
(Example)

Output

The above program produces the following output. This will depend on the current date and time on the system, on which the program is being run.
03/01/2016

getTime

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

Syntax

Following is the syntax.
(.getTime)
Parameters − None.
Return Value − The number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.

Example

An example on how this is used is shown in the following program.
(ns example)
(import java.util.Date)
(defn Example []
   (def date (.getTime (java.util.Date.)))
   (println date))
(Example)

Output

The above program produces the following output. This will depend on the current date and time on the system, on which the program is being run.
1456812778160

No comments:

Post a Comment