@@ -26,7 +26,7 @@ You need a valid 'IPGeolocation API key' to use this SDK. [Sign up](https://ipge
2626free API key if you don’t have one.
2727
2828** Note:** Complete documentation to use this SDK is also available
29- at [ IP Geolocation API JAVA SDK Documentation] ( https://ipgeolocation.io/documentation/ip-geolocation-api-java-sdk-20180807094025 )
29+ at [ IP Geolocation API JAVA SDK Documentation] ( https://ipgeolocation.io/documentation/ip-geolocation-api-java-sdk.html )
3030.
3131
3232## System Requirements
@@ -90,7 +90,7 @@ Basic Usage
9090
9191``` java
9292// Create IPGeolocationAPI object, passing your valid API key
93- IPGeolocationAPI api = new IPGeolocationAPI (" YOUR_API_KEY" );
93+ IPGeolocationAPI ipGeolocationAPI = new IPGeolocationAPI (" YOUR_API_KEY" );
9494```
9595
9696### Geolocation Lookup
@@ -107,15 +107,21 @@ GeolocationParams geolocationParams =
107107try {
108108 Geolocation geolocation = ipGeolocationAPI. getGeolocation(geolocationParams);
109109
110- System . out. println(geolocation. getCountryName());
111- System . out. println(geolocation. getCurrency(). getName());
112- System . out. println(geolocation. getTimezone(). getCurrentTime());
113- System . out. println(geolocation. getGeolocationSecurity(). getAnonymous());
114- System . out. println(geolocation. getGeolocationSecurity(). getKnownAttacker());
115- System . out. println(geolocation. getGeolocationSecurity(). getProxy());
116- System . out. println(geolocation. getGeolocationSecurity(). getProxyType());
117- System . out. println(geolocation. getGeolocationSecurity(). getAnonymous());
118- System . out. println(geolocation. getGeolocationSecurity(). getCloudProvider());
110+ // Geolocation Info
111+ System . out. println(" Country: " + geolocation. getCountryName());
112+ System . out. println(" Currency: " + geolocation. getCurrency(). getName());
113+ System . out. println(" Location time: " + geolocation. getTimezone(). getCurrentTime());
114+
115+ // Security Info
116+ System . out. println(" Is Anonymous: " + geolocation. getGeolocationSecurity(). isAnonymous());
117+ System . out. println(" Is Known Attacker: " + geolocation. getGeolocationSecurity(). isKnownAttacker());
118+ System . out. println(" Is Proxy: " + geolocation. getGeolocationSecurity(). isProxy());
119+ System . out. println(" Proxy Type: " + geolocation. getGeolocationSecurity(). getProxyType());
120+ System . out. println(" IP Threat Score: " + geolocation. getGeolocationSecurity(). getThreatScore());
121+ System . out. println(" Is Bot: " + geolocation. getGeolocationSecurity(). isBot());
122+ System . out. println(" Is Spam: " + geolocation. getGeolocationSecurity(). isSpam());
123+ System . out. println(" Is Tor: " + geolocation. getGeolocationSecurity(). isTor());
124+ System . out. println(" Is Cloud Provider: " + geolocation. getGeolocationSecurity(). isCloudProvider());
119125} catch (IPGeolocationError e) {
120126 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
121127 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -132,8 +138,8 @@ GeolocationParams geolocationParams =
132138try {
133139 Geolocation geolocation = ipGeolocationAPI. getGeolocation(geolocationParams);
134140
135- System . out. println(geolocation. getIP());
136- System . out. println(geolocation. getCountryName());
141+ System . out. println(" IP Address: " + geolocation. getIP());
142+ System . out. println(" Country: " + geolocation. getCountryName());
137143} catch (IPGeolocationError e) {
138144 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
139145 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -144,9 +150,9 @@ try {
144150try {
145151 Geolocation geolocation = ipGeolocationAPI. getGeolocation();
146152
147- System . out. println(geolocation. getIP());
148- System . out. println(geolocation. getCountryCode2());
149- System . out. println(geolocation. getTimezone(). getCurrentTime());
153+ System . out. println(" IP Address: " + geolocation. getIP());
154+ System . out. println(" Country Code ISO2: " + geolocation. getCountryCode2());
155+ System . out. println(" Location time: " + geolocation. getTimezone(). getCurrentTime());
150156} catch (IPGeolocationError e) {
151157 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
152158 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -159,16 +165,16 @@ try {
159165String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
160166GeolocationParams geolocationParams =
161167 GeolocationParams . builder()
162- .withLand (" de" )
168+ .withLang (" de" )
163169 .build();
164170
165171try {
166- List<Geolocation > geolocations = ipGeolocationAPI. getBulkGeolocation(ips, geoParams );
172+ List<Geolocation > geolocations = ipGeolocationAPI. getBulkGeolocation(ips, geolocationParams );
167173
168- System . out. println(geolocations. size());
169- System . out. println(geolocations. get(0 ). getCountryName());
170- System . out. println(geolocations. get(1 ). getLanguages());
171- System . out. println(geolocations. get(2 ). getTimezone(). getCurrentTime());
174+ System . out. println(" No. of Requests: " + geolocations. size());
175+ System . out. println(" 1st IP's Country: " + geolocations. get(0 ). getCountryName());
176+ System . out. println(" 2nd IP's Language: " + geolocations. get(1 ). getLanguages());
177+ System . out. println(" 3rd IP's location time: " + geolocations. get(2 ). getTimezone(). getCurrentTime());
172178} catch (IPGeolocationError e) {
173179 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
174180 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -183,12 +189,12 @@ GeolocationParams geolocationParams =
183189 .build();
184190
185191try {
186- List<Geolocation > geolocations = ipGeolocationAPI. getBulkGeolocation(ips, geoParams );
192+ List<Geolocation > geolocations = ipGeolocationAPI. getBulkGeolocation(ips, geolocationParams );
187193
188- System . out. println(geolocations. size());
189- System . out. println(geolocations. get(0 ). getCountryName());
190- System . out. println(geolocations. get(1 ). getLanguages ());
191- System . out. println(geolocations. get(2 ). getTimezone() . getCurrentTime ());
194+ System . out. println(" No. of Requests: " + geolocations. size());
195+ System . out. println(" 1st IP's Country: " + geolocations. get(0 ). getCountryName());
196+ System . out. println(" 2nd IP's City: " + geolocations. get(1 ). getCity ());
197+ System . out. println(" 3rd IP's City Zipcode: " + geolocations. get(2 ). getZipCode ());
192198} catch (IPGeolocationError e) {
193199 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
194200 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -202,10 +208,10 @@ TimezoneParams timezoneParams =
202208 TimezoneParams . builder(). withTimeZone(" America/New_York" ). build();
203209
204210try {
205- Timezone tz = ipGeolocationAPI. getTimezone(tzParams );
211+ Timezone tz = ipGeolocationAPI. getTimezone(timezoneParams );
206212
207- System . out. println(tz. getDateTimeWti ());
208- System . out. println(tz. getDateTimeTxt ());
213+ System . out. println(" Format 'EEEE, MMMM dd, yyyy HH:mm:ss': " + tz. getDateTimeTxt ());
214+ System . out. println(" Format 'EEE, dd MMM yyyy HH:mm:ss Z': " + tz. getDateTimeWti ());
209215} catch (IPGeolocationError e) {
210216 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
211217 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -219,30 +225,36 @@ TimezoneParams timezoneParams =
219225 .build();
220226
221227try {
222- Timezone tz = ipGeolocationAPI. getTimezone(tzParams );
228+ Timezone tz = ipGeolocationAPI. getTimezone(timezoneParams );
223229
224- System . out. println(tz. getTimezone());
225- System . out. println(tz. getDateTimeWti ());
226- System . out. println(tz. getDateTimeTxt ());
230+ System . out. println(" Timezone: " + tz. getTimezone());
231+ System . out. println(" Timezone in Unix: " + tz. getDateTimeUnix ());
232+ System . out. println(" Time in 24 format: " + tz. getTime24 ());
227233} catch (IPGeolocationError e) {
228234 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
229235 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
230236}
231237```
232238``` java
233- // Get time zone information for IP address (1.1.1.1) and geolocation information Japanese**
239+ // Get time zone information for IP address (1.1.1.1) and geolocation information in Japanese**
234240TimezoneParams timezoneParams =
235241 TimezoneParams . builder()
236242 .withIPAddress(" 1.1.1.1" )
237243 .withLang(" ja" )
238244 .build();
239245
240246try {
241- Timezone tz = ipGeolocationAPI. getTimezone(tzParams );
247+ Timezone tz = ipGeolocationAPI. getTimezone(timezoneParams );
242248
243- System . out. println(tz. getTimezone());
244- System . out. println(tz. getDateTimeWti());
245- System . out. println(tz. getDateTimeTxt());
249+ // Timezone Info
250+ System . out. println(" Timezone: " + tz. getTimezone());
251+ System . out. println(" Format 'EEEE, MMMM dd, yyyy HH:mm:ss': " + tz. getDateTimeTxt());
252+ System . out. println(" Format 'yyyy-MM-dd'T'HH:mm:ssZ': " + tz. getDateTimeYmd());
253+
254+ // Geo Info
255+ System . out. println(" City: " + tz. getGeo(). getCity());
256+ System . out. println(" State/Province: " + tz. getGeo(). getStateProvince());
257+ System . out. println(" Country: " + tz. getGeo(). getCountryName());
246258} catch (IPGeolocationError e) {
247259 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
248260 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
@@ -253,9 +265,15 @@ try {
253265try {
254266 Timezone tz = ipGeolocationAPI. getTimezone();
255267
256- System . out. println(tz. getTimezone());
257- System . out. println(tz. getDateTimeWti());
258- System . out. println(tz. getDateTimeYmd());
268+ // Timezone Info
269+ System . out. println(" Timezone Offset: " + tz. getTimezoneOffset());
270+ System . out. println(" Date: " + tz. getDate());
271+ System . out. println(" Month (No.): " + tz. getMonth());
272+
273+ // Geo Info
274+ System . out. println(" City: " + tz. getGeo(). getCity());
275+ System . out. println(" Country Code ISO3: " + tz. getGeo(). getCountryCode3());
276+ System . out. println(" Lat/Lon: " + tz. getGeo(). getLatitude() + " /" + tz. getGeo(). getLongitude());
259277} catch (IPGeolocationError e) {
260278 // on unsuccessful lookup or invalid input IPGeolocationError is thrown
261279 System . err. println(" HTTP status: " + e. getStatus() + " Error: " + e. getMessage());
0 commit comments