Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
5
Task/Date-format/Java/date-format-1.java
Normal file
5
Task/Date-format/Java/date-format-1.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
public static void main(String[] args) {
|
||||
long millis = System.currentTimeMillis();
|
||||
System.out.printf("%tF%n", millis);
|
||||
System.out.printf("%tA, %1$tB %1$td, %1$tY%n", millis);
|
||||
}
|
||||
18
Task/Date-format/Java/date-format-2.java
Normal file
18
Task/Date-format/Java/date-format-2.java
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.DateFormat;
|
||||
public class Dates{
|
||||
public static void main(String[] args){
|
||||
Calendar now = new GregorianCalendar(); //months are 0 indexed, dates are 1 indexed
|
||||
DateFormatSymbols symbols = new DateFormatSymbols(); //names for our months and weekdays
|
||||
|
||||
//plain numbers way
|
||||
System.out.println(now.get(Calendar.YEAR) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE));
|
||||
|
||||
//words way
|
||||
System.out.print(symbols.getWeekdays()[now.get(Calendar.DAY_OF_WEEK)] + ", ");
|
||||
System.out.print(symbols.getMonths()[now.get(Calendar.MONTH)] + " ");
|
||||
System.out.println(now.get(Calendar.DATE) + ", " + now.get(Calendar.YEAR));
|
||||
}
|
||||
}
|
||||
13
Task/Date-format/Java/date-format-3.java
Normal file
13
Task/Date-format/Java/date-format-3.java
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
public class Dates
|
||||
{
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
//using DateTimeFormatter
|
||||
LocalDate date = LocalDate.now();
|
||||
DateTimeFormatter dtFormatter = DateTimeFormatter.ofPattern("yyyy MM dd");
|
||||
|
||||
System.out.println(dtFormatter.format(date));
|
||||
}
|
||||
}
|
||||
11
Task/Date-format/Java/date-format-4.java
Normal file
11
Task/Date-format/Java/date-format-4.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class DateFormat {
|
||||
public static void main(String[]args){
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat formatLong = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
|
||||
System.out.println(format.format(new Date()));
|
||||
System.out.println(formatLong.format(new Date()));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue