Skip to content

Tag: java

Android: location; activity and service

I’m working on some application that should fetch current location and after device is located in some radius should be shown application with some message. I have a few questions. I’m trying to fetch location using If I use requestLocationUpdates then GPS is always working. And this is a waste of…

In Java, what is the fastest way to get the system time?

I’m developing a system that often use the system time because the Delayed interface. What is fastet way to get the time from system? Currently I’m using Calendar.getInstance().getTimeInMillis() every time I need to get the time, but I don’t know if there is a faster way. Answer System.curre…

Head First Design Patterns – Combined Pattern

I’m reading the chapter 12 on the Combined Pattern in Head First Design Patterns. On page 541,the sample DJView,it cant’t run correctly in my computer.when i press the ‘start’, the program only sounds once rather than circularly . i’m not sure whether because of the environment o…

Conversion from 12 hours time to 24 hours time in java

In my app, I have a requirement to format 12 hours time to 24 hours time. What is the method I have to use? For example, time like 10:30 AM. How can I convert to 24 hours time in java? Answer Try this: which produces: See: http://download.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html