date format in android

import java.time.*;
import java.time.format.*;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime datetime = LocalDateTime.now();
String output = formatter.format(datetime);

4.5
2
Awgiedawgie 440220 points

                                    import java.time.*;
import java.time.format.*;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime time = LocalTime.now();
String output = formatter.format(time);

4.5 (2 Votes)
0
5
1
Krish 100200 points

                                    String date="Mar 10, 2016 6:30:00 PM";
SimpleDateFormat spf=new SimpleDateFormat("MMM dd, yyyy hh:mm:ss aaa");
Date newDate=spf.parse(date);
spf= new SimpleDateFormat("dd MMM yyyy");
date = spf.format(newDate);
System.out.println(date);

5 (1 Votes)
0
4
1
Phoenix Logan 186120 points

                                    startTime = "2013-02-27 21:06:30";
StringTokenizer tk = new StringTokenizer(startTime);
String date = tk.nextToken();  
String time = tk.nextToken();

SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
SimpleDateFormat sdfs = new SimpleDateFormat("hh:mm a");
Date dt;
try {    
    dt = sdf.parse(time);
    System.out.println("Time Display: " + sdfs.format(dt)); // <-- I got result here
} catch (ParseException e) {
    e.printStackTrace();
}

4 (1 Votes)
0
4
6
Awgiedawgie 440220 points

                                    import java.time.*;
import java.time.format.*;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.now();
String output = formatter.format(date);

4 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
get date from string format android date format in xml android simpledate format android date format java android android date format library convert date format in android Android java format date DateFormat date java android how to convert date format in android date formate in android android format time from - to date format android studio how to format string date in android studio date and time format in android studio date formate in android studio in which format we can use date in android how to format datetime in java in android studio how to format date in android studio format time android android date valitator format android datetime format android format datetime android studio date time format android date formatter format date time to date android how to get Date in android studio custom format set date format android android string date format android studio custom date and time format android studio date formats date android format How to format data and time in android studio dateformat android studio android format date string android time format android dateformat android simple date format android java formatting date android date format string android studio date format what is the formate of androids Date() java android date format date format in android programmatically get formatted date and time android dateformat java android format date android simple date format in android string time format android time string format android string date format android date and time formatting in android fromiso format date formatting in android how to format date in time picker in android studio date format entry android studio Format Date string android java fomat datetime format in android android studio format date object time format android format time android studio android format java date format date in android xml date format in android studio android format time android date format android: format date format date in android android date time format android different date formats android time formate android java time format examples format date string android format in date in android us date and time format android programmatically Android date formatting android java get date format string format date in android android java string time format date format android dateformat android example date format current date android Date formatter Android format date android java how to format date and time in android DateFormat android android get date in format date format list android date format types android get date android studio custom format datetime format android date time formatting android studio\ date time formating android studio\ datetime format in java android date format in android android java date format how use DateFormat in android java simple date format android android java parse date android date android dateformat examples android format date android java parse date time android java format date time
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source