Notes
Notes - notes.io |
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.Period;
import java.time.format.DateTimeFormatter;
public class Fechas {
public static void main (String ... a){
LocalDate d1 = LocalDate.of(2019, Month.MARCH, 1);
LocalDate d2 = LocalDate.of(2019, 10, 1);
LocalTime t1 = LocalTime.of(22, 40);
LocalTime t2 = LocalTime.of(22, 40, 33);
LocalTime t3 = LocalTime.of(22, 40, 33, 56);
LocalDateTime dt1 = LocalDateTime.of(2019, Month.MARCH, 2, 22, 30);
LocalDateTime dt2 = LocalDateTime.of(2019, 10, 2, 22, 30, 40);
System.out.println(d1);
d1.plusDays(1); // d1 no se modifica
d2.plusMonths(2);
t1.plusMinutes(3);
dt1.plusWeeks(3);
System.out.println(d1);
System.out.println(d1.plusDays(1));
Period p = Period.of(1,2,18);
System.out.println(p); // P1Y2M18D
System.out.println(d1.plus(p)); // 2020-05-19
Duration d = Duration.ofMinutes(10); // PT10M
Duration d3 = Duration.ofDays(1).ofMinutes(10); // PT10M
Duration d4 = Duration.ofDays(1).plusMinutes(10); // PT24H10M
d = d.plusSeconds(30);
d = d.plusDays(1);
System.out.println(d); // PT24H10M30S
Duration dd = Duration.between(t1,t2);
System.out.println(dd); // PT33S
System.out.println(Duration.between(t2,t1)); // PT-33S
LocalDate d5 = LocalDate.parse("2019-05-12", DateTimeFormatter.ISO_DATE);
}
}
import java.time.DateTimeException;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAdjusters;
import java.util.Scanner;
public class birthday {
public static void main(String ... args){
Scanner in = new Scanner(System.in);
LocalDate cumple = null;
do{
System.out.println("Fecha del día de tu nacimiento (d/M/yyyy)");
String input = in.nextLine();
try{
cumple=cumple.parse(input,DateTimeFormatter.ofPattern("d/M/yyyy"));
}catch(DateTimeParseException e){
System.out.println("Formato no válido: "+e);
}catch(DateTimeException e2){
System.out.println("Fecha no válida: "+e2);
}
}while(cumple==null);
System.out.println("Día de la semana:" + cumple.getDayOfWeek());
LocalDate fiesta = cumple.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY));
System.out.println("Fecha fiesta: "+ fiesta);
System.out.println("Hora fiesta: " + LocalDateTime.of(fiesta,LocalTime.of(21,30)));
System.out.println("Aviso fiesta: " + fiesta.minusDays(10));
}
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class ListTest {
public static void main (String ... args){
List <String> names = new ArrayList<>();
names.add("sergi");
names.add("pepe");
names.add("juan");
names.add("sergi");
names.remove("sergi");
names.remove(1);
System.out.println(names); // [pepe,sergi]
List<Integer> numbers = new ArrayList<>();
numbers.add(1);
numbers.add(2);
numbers.add(3);
numbers.remove(1); // posición 1
numbers.remove(new Integer(3));
System.out.println(numbers); // [1]
numbers = new ArrayList<>(Arrays.asList(1,2,3,4,5));
System.out.println(numbers); // [1, 2, 3, 4, 5]
numbers.set(0,5);
numbers.clear();
if(numbers.isEmpty() || numbers.contains(4)){
}
Integer [] numbersArray = numbers.toArray(new Integer[0]);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.mavenproject1;
import java.math.BigDecimal;
/**
*
* @author javaed
*/
public class Importe implements Comparable<Importe>{
private BigDecimal cantidad;
private String divisa;
@Override
public int compareTo(Importe t){
return cantidad.compareTo(t.cantidad);
}
}
|
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team