Skip to content

Commit 1963ccb

Browse files
authored
Merge pull request #27 from coderolls/update-blogpost
Update groovy object datatype and java timestamp blogpost
2 parents 2cbca5f + a7f153e commit 1963ccb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

_posts/groovy/2021-05-11-determine-a-datatype-in-groovy.md

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class java.util.ArrayList
4242
class java.lang.String
4343
java.lang.String
4444
```
45+
See above code as [GitHub Gist](https://gist.github.com/gauravkukade/1c12a2e35d8803106d4cf2b0e11f6b18#file-determine-datatype-groovy)
46+
4547
In the above program, we can see that the `names` is an `ArrayList` and `blogname` is a `String` object.
4648

4749
When we call the `getClass()` method on these objects it prints its respective datatype.
@@ -68,6 +70,7 @@ Output:
6870
true
6971
false
7072
```
73+
See above code as [GitHub Gist](https://gist.github.com/gauravkukade/eafc65547cd3cd54877ca5d54eec8acc)
7174

7275
In the above program, I have defined one String `blogname`. I have used the `instanceof` keyword to check if the `blogname` implements the `String` class and it prints `true`. It means the `blogname` is an instance of the `String` class.
7376

@@ -92,6 +95,8 @@ That's it about checking the datatype of an object in Groovy.
9295

9396
If you know any other way to check the datatype of an object, please comment below to help the community. Thank you.
9497

98+
You can check my YouTube channel [here](https://www.youtube.com/channel/UCl31HHUdQbSHOQfc9L-wo3w)
99+
95100
### Related Articles
96101

97102
- [Hello World In Groovy](https://coderolls.com/hello-world-in-groovy/)

_posts/java-time/2021-05-13-how-to-get-current-timestamps-in-java.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ Output:
7474
4. timeStampMillis: 1620919459988
7575
5. timeStampSeconds: 1620919459
7676
```
77+
See above code as [GitHub Gist](https://gist.github.com/gauravkukade/b1ceabac137864efd7258b60610cd9dd)
78+
7779
### Explanation:
7880

7981
1. In the first case, we have used the `.now()` method of the `Instant` class to get the current timestamp.
@@ -118,6 +120,8 @@ Output:
118120
2. timestampFromDateObject: 2021-05-13 20:55:44.187
119121
```
120122

123+
See above code as [GitHub Gist](https://gist.github.com/gauravkukade/a965f1a078d382ff7366e7ba6d13561c)
124+
121125
### Explanation:
122126

123127
1. In the first case, we are got the `timestamp` using the system time in milliseconds. We can get the system time in millisecond using the `System.currentTimeMillis()`.
@@ -158,6 +162,8 @@ Output:
158162
```
159163
Instant To Timestamp: 2021-05-13 21:07:44.381
160164
```
165+
See above code as [GitHub Gist](https://gist.github.com/gauravkukade/ea3bc951f15be0010569d306ccafa975)
166+
161167
### Explanation:
162168

163169
In the above example, we have used `.from()` of the `Timestamp` class to get the current timestamp from the `instant` object.
@@ -199,6 +205,8 @@ Output:
199205
```
200206
Timestamp To Instant: 2021-05-13T15:39:08.046Z
201207
```
208+
See above code as [GitHub Gist](https://gist.github.com/gauravkukade/a031b1904d4efaf758a59462ee2dc02e)
209+
202210
### Explanation:
203211

204212
In the above example, we have used the `.toInstant()` method on the `timestamp` object to get the current timestamp (as Instant ).
@@ -267,7 +275,7 @@ If you have any queries about the above article, please comment below. Thanks.
267275

268276
We will see how to get the current date-time in java. Also, we will see how we can format them using the SimpleDateFormat.
269277

270-
You can check my YouTube channel at: https://www.youtube.com/channel/UCl31HHUdQbSHOQfc9L-wo3w
278+
You can check my YouTube channel [here](https://www.youtube.com/channel/UCl31HHUdQbSHOQfc9L-wo3w)
271279

272280
### Related Articles
273281

0 commit comments

Comments
 (0)