Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calendar c = Calendar.getInstance();
- int seconds = c.get(Calendar.SECOND);
- Time now = new Time();
- now.setToNow();
- Time time = new Time(); time.setToNow();
- Log.d("TIME TEST", Long.toString(time.toMillis(false)));
- ... do something that takes more than one millisecond, but less than one second ...
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
- String currentDateandTime = sdf.format(new Date());
- Time today = new Time(Time.getCurrentTimezone());
- today.setToNow();
- textViewDay.setText(today.monthDay + ""); // Day of the month (1-31)
- textViewMonth.setText(today.month + ""); // Month (0-11)
- textViewYear.setText(today.year + ""); // Year
- textViewTime.setText(today.format("%k:%M:%S")); // Current time
- DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy, HH:mm");
- String date = df.format(Calendar.getInstance().getTime());
- "yyyy.MM.dd G 'at' HH:mm:ss z" ---- 2001.07.04 AD at 12:08:56 PDT
- "hh 'o''clock' a, zzzz" ----------- 12 o'clock PM, Pacific Daylight Time
- "EEE, d MMM yyyy HH:mm:ss Z"------- Wed, 4 Jul 2001 12:08:56 -0700
- "yyyy-MM-dd'T'HH:mm:ss.SSSZ"------- 2001-07-04T12:08:56.235-0700
- "yyMMddHHmmssZ"-------------------- 010704120856-0700
- "K:mm a, z" ----------------------- 0:08 PM, PDT
- "h:mm a" -------------------------- 12:08 PM
- "EEE, MMM d, ''yy" ---------------- Wed, Jul 4, '01
- String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
- Feb 27, 2012 5:41:23 PM
- Date currentDate = new Date(System.currentTimeMillis());
- Time currentTime = new Time();
- currentTime.setToNow();
- Calendar cal = Calendar.getInstance();
- int millisecond = cal.get(Calendar.MILLISECOND);
- int second = cal.get(Calendar.SECOND);
- int minute = cal.get(Calendar.MINUTE);
- //12 hour format
- int hour = cal.get(Calendar.HOUR);
- //24 hour format
- int hourofday = cal.get(Calendar.HOUR_OF_DAY);
- Calendar cal = Calendar.getInstance();
- int dayofyear = cal.get(Calendar.DAY_OF_YEAR);
- int year = cal.get(Calendar.YEAR);
- int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
- int dayofmonth = cal.get(Calendar.DAY_OF_MONTH);
- String currentDateTimeString = DateFormat.getDateInstance().format(new Date());
- // textView is the TextView view that should display it
- textView.setText(currentDateTimeString);
- Calendar c = Calendar.getInstance();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String strDate = sdf.format(c.getTime());
- 2014-11-11 00:47:55
- final Calendar c = Calendar.getInstance();
- int mYear = c.get(Calendar.YEAR);
- int mMonth = c.get(Calendar.MONTH);
- int mDay = c.get(Calendar.DAY_OF_MONTH);
- textView.setText(""+mDay+"-"+mMonth+"-"+mYear);
- Time time = new Time();
- time.setToNow();
- System.out.println("time: " + time.hour+":"+time.minute);
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- Calendar cal = Calendar.getInstance();
- System.out.println("time => " + dateFormat.format(cal.getTime()));
- String time_str = dateFormat.format(cal.getTime());
- String[] s = time_str.split(" ");
- for (int i = 0; i < s.length; i++) {
- System.out.println("date => " + s[i]);
- }
- int year_sys = Integer.parseInt(s[0].split("/")[0]);
- int month_sys = Integer.parseInt(s[0].split("/")[1]);
- int day_sys = Integer.parseInt(s[0].split("/")[2]);
- int hour_sys = Integer.parseInt(s[1].split(":")[0]);
- int min_sys = Integer.parseInt(s[1].split(":")[1]);
- System.out.println("year_sys => " + year_sys);
- System.out.println("month_sys => " + month_sys);
- System.out.println("day_sys => " + day_sys);
- System.out.println("hour_sys => " + hour_sys);
- System.out.println("min_sys => " + min_sys);
- Time now = new Time();
- now.setToNow();
- Time t = new Time(Time.getCurrentTimezone());
- t.setToNow();
- String date = t.format("%Y/%m/%d");
- Date todayDate = new Date();
- todayDate.getDay();
- todayDate.getHours();
- todayDate.getMinutes();
- todayDate.getMonth();
- todayDate.getTime();
- SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ",Locale.ENGLISH);
- String cDateTime=dateFormat.format(new Date());
- String Datetime;
- Calendar c = Calendar.getInstance();
- SimpleDateFormat dateformat = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss aa");
- Datetime = dateformat.format(c.getTime());
- System.out.println(Datetime);
- Calendar cal = Calendar.getInstance();
- String date = ""+cal.get(Calendar.DATE)+"-"+(cal.get(Calendar.MONTH)+1)+"-"+cal.get(Calendar.YEAR);
- String time = ""+cal.get(Calendar.HOUR_OF_DAY)+":"+cal.get(Calendar.MINUTE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement