Friday, February 13, 2015

Current local time in UTC

   
        try {
            Calendar calendar = Calendar.getInstance();
            int month = calendar.getTime().getMonth() + 1;
            String timeStampToMatch = calendar.getTime().getDate() + "-"
                    + month + "-" + calendar.get(Calendar.YEAR) + " "
                    + "01:01 pm";

            Log.i("======>", timeStampToMatch);

            DateFormat dateFormat = new SimpleDateFormat("d-M-yyyy H:m");

            Date date = dateFormat.parse(timeStampToMatch);
            dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
            Log.i("======>", dateFormat.format(date));

        } catch (ParseException e) {
            e.printStackTrace();
        }


Using common Layout and its event in all activities

ViewGroup vg = (ViewGroup) findViewById(R.id.lldata);
ViewGroup.inflate(getApplicationContext(), R.layout.listwitter, vg);